Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """Day 5 -- Advent of Code 2017"""
- # Open and parse input to form our list of jump instructions.
- with open('Day5input.txt', 'r') as f:
- instructions = list(map(int, [s.strip() for s in f.readlines()]))
- # test = [0, 3, 0, 1, -3]
- # instructions = test
- cnt = 0
- cur_index = 0
- while True:
- # print(test)
- try:
- jump_val = instructions[cur_index]
- next_index = cur_index + jump_val
- # instructions[cur_index] += 1 # PART ONE
- instructions[cur_index] += (-1 if jump_val >= 3 else 1) # PART TWO
- cur_index = next_index
- except IndexError:
- break
- cnt += 1
- print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment