aoc2017day05-2
import sys
def day5_2(input):
maze = list(map(lambda x: int(x.rstrip()), input.split()))
size = len(maze)
steps = 0
pc = 0
while pc >= 0 and pc < size:
offset = maze[pc]
if offset >= 3: maze[pc] -= 1
else: maze[pc] += 1
pc += offset
steps += 1
return "%d" % steps
input = sys.stdin.read()
print(day5_2(input))
INFO