diff --git a/2016/ruby/day_18.rb b/2016/ruby/day_18.rb index 1ea0030..86bbb9e 100644 --- a/2016/ruby/day_18.rb +++ b/2016/ruby/day_18.rb @@ -26,11 +26,12 @@ end if __FILE__ == $0 row = Row.from_s(DATA.read.chomp) - rows = [row] - while rows.size < 40 - rows << rows.last.next + count = 0 + 400_000.times do + count += row.tiles.count(:safe) + row = row.next end - p rows.map {|row| row.tiles.count(:safe) }.inject(:+) + p count end require 'minitest'