adventofcode

https://adventofcode.com/
Log | Files | Refs

puzzle5.py (612B)


      1 from sets import Set
      2 
      3 with open('files/puzzle5.txt') as f:
      4     instructions = [int(i) for i in f.readlines()]
      5 
      6 pointer = 0
      7 step_counter = 0
      8 instructions2 = list(instructions)
      9 
     10 while pointer < len(instructions):
     11     temp = pointer
     12     pointer += instructions[pointer]
     13     instructions[temp] += 1
     14     step_counter += 1
     15 
     16 print step_counter
     17 
     18 pointer = 0
     19 step_counter = 0
     20 
     21 while pointer < len(instructions2):
     22     temp = pointer
     23     pointer += instructions2[pointer]
     24     if instructions2[temp] >= 3:
     25         instructions2[temp] -= 1
     26     else:
     27         instructions2[temp] += 1
     28     step_counter += 1
     29 
     30 print step_counter