#!/usr/bin/env python # -*- coding: utf-8 -*- inputs = ["part1.txt", "input.txt"] def solve(filename): mylist = [] with open(filename, "r") as fp: for line in fp: mylist.append(int(line)) pos = 0 total = len(mylist) - 1 steps = 0 while True: oldpos = pos pos = pos + mylist[pos] mylist[oldpos] = mylist[oldpos] + 1 steps = steps + 1 if pos > total: break return steps for puzzle in inputs: print(puzzle, solve(puzzle))