#!/usr/bin/env python3 # input file has an integer on every line # pointer starts at the first line # each 'jump' moves by the value of the line # positive goes downward, negative goes upward # after the jump, increment the jumping-off line by +1 if __name__ == '__main__': with open("input", "r", encoding="utf-8") as maze_file: maze_strings = maze_file.readlines() maze_size = len(maze_strings) maze_ints = [] for i in range(maze_size): maze_ints.append(int(maze_strings[i])) pointer = 0 jumps = 0 while pointer < maze_size and pointer >= 0: current_value = maze_ints[pointer] maze_ints[pointer] = current_value + 1 jumps += 1 pointer += current_value print(f'finally, jumping from {current_value} at {pointer - current_value}, you missed {pointer}!') print(f'it took {jumps} jumps!')