2015/day10.rb

28 lines
418 B
Ruby
Raw Normal View History

2022-12-04 02:42:29 +00:00
$input = ARGF.read.chomp.chars.map { |c| c.to_i }
def solve(n)
n.times do
new_input = []
current = $input[0]
count = 0
$input.each do |c|
if c == current then
count += 1
else
new_input << count << current
current = c
count = 1
end
end
new_input << count << current
$input = new_input
end
puts $input.size
end
solve(40)
solve(10)