21 lines
535 B
Ruby
21 lines
535 B
Ruby
input = File.open('puzzle_6.txt').read.split(' ').map(&:to_i)
|
|
combinations = [ input.dup ]
|
|
while(true) do
|
|
to_distribute = input.max
|
|
start_at = input.index to_distribute
|
|
input[start_at] = 0
|
|
start_at += 1
|
|
while(to_distribute > 0) do
|
|
start_at %= input.length
|
|
to_distribute -= 1
|
|
input[start_at] += 1
|
|
start_at += 1
|
|
end
|
|
if(combinations.include? input) then
|
|
puts combinations.index input
|
|
break
|
|
end
|
|
combinations.push input.clone
|
|
end
|
|
puts combinations.length
|