This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BowlingGame | |
attr_reader :rolls | |
def initialize(rolls) | |
@rolls = rolls | |
end | |
def score | |
(1..10).reduce([]) { |frame_calc_a, frame_number| | |
frame_calc_a << rolls[range(frame_number)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class BowlingGame | |
attr_reader :rolls | |
def initialize(rolls) | |
@rolls = rolls | |
end | |
def score | |
(1..10).map { |frame_number| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
describe "LifeGame" do | |
ALIVE = 1 | |
DEAD = 0 | |
subject { Space.new(seed).next_time.status(1,1) } | |
context "誕生:死んでいるセルに隣接する生きたセルがちょうど3つあれば次世代が誕生する" do | |
let(:seed) {[ [1,1,0], | |
[1,0,0], | |
[0,0,0]]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calc | |
constructor: -> | |
@enters = [] | |
enter: (n)-> | |
@enters.push n | |
add: -> | |
added = this.roman_to_num(@enters[0]) + this.roman_to_num(@enters[1]) | |
if (added >= 4000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.CoreMatchers.not; | |
import static org.junit.Assert.assertThat; | |
import static org.junit.matchers.JUnitMatchers.hasItems; | |
import java.util.List; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.experimental.theories.DataPoints; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
class IfThenElse | |
def initialize(&block) | |
yield self | |
end | |
def exec | |
if @if.call | |
@then.call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
class And | |
def initialize(*node) | |
@node = node | |
end | |
def exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class RouteMap | |
def initialize(&block) | |
@links = [] | |
block.call(self) if block_given? | |
end | |
def link(station_a, station_b, time_cost=0) | |
@links << Link.new(station_a, station_b, time_cost) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using NUnit.Framework; | |
using NUnit.Framework.Constraints; | |
namespace sudoku { | |
[TestFixture] | |
public class SudokuBoardTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
module LifeGame | |
describe "Spaceの中央セルの状態について" do | |
subject { Space.start(seeds).next_time.status(1, 1) } | |
context "誕生:死んでいるセルに隣接する生きたセルがちょうど3つあれば次世代が誕生する" do | |
let(:seeds) {[ [1,1,0], | |
[1,0,0], |