28 lines
418 B
Ruby
28 lines
418 B
Ruby
$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)
|