[2016][ruby][18.0] solution

profile
Alpha Chen 8 years ago
parent b4335dda72
commit 2e1eba56a5

@ -24,7 +24,17 @@ Row = Struct.new(:tiles) do
end
end
require 'minitest/autorun'
if __FILE__ == $0
row = Row.from_s(DATA.read.chomp)
rows = [row]
while rows.size < 40
rows << rows.last.next
end
p rows.map {|row| row.tiles.count(:safe) }.inject(:+)
end
require 'minitest'
# require 'minitest/autorun'
class TestRow < Minitest::Test
def test_row
@ -34,3 +44,6 @@ class TestRow < Minitest::Test
assert_equal Row.from_s('.^^^^'), row.next
end
end
__END__
^^.^..^.....^..^..^^...^^.^....^^^.^.^^....^.^^^...^^^^.^^^^.^..^^^^.^^.^.^.^.^.^^...^^..^^^..^.^^^^

Loading…
Cancel
Save