blob: 0d0b4ecc1308c3d680fc4dc74f862b1e84834e5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/usr/bin/env ruby
input = $stdin.readlines.map(&:chomp).map(&:to_i)
pc = 0
steps = 0
while pc >= 0 && pc < input.length do
newpc = pc + input[pc]
input[pc] += 1
pc = newpc
steps += 1
end
puts steps
|