aboutsummaryrefslogtreecommitdiff
path: root/day05/part2
blob: 333d5d4bc4027071363900bcb9ba4e83dcf925a7 (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] += input[pc] >= 3 ? -1 : 1
  pc = newpc
  steps += 1
end

puts steps