Quick actions

cmd+k|ctrl+k

Navigation

Languages

aoc2017day05

Snippet info

Language

Python

Visibility

public

Author

christophe.guillon.perso

Created

2017-12-05T05:32:14Z

Updated

2017-12-05T05:33:38Z

import sys

def day5(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]
        maze[pc] += 1
        pc += offset
        steps += 1
    return "%d" % steps

input = sys.stdin.read()
print(day5(input))
INFO