Something went wrong. Try again.
My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code
advent-of-code python
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233import fileinput
INSTR = []
for line in fileinput.input(): INSTR.append(int(line))
# Part 1instr = INSTR[:]steps = 0i = 0
while 0 <= i < len(instr): jump_to = instr[i] + i instr[i] += 1 i = jump_to steps += 1
print "Steps to reach exit (part 1):", steps
# Part 2instr = INSTR[:]steps = 0i = 0
while 0 <= i < len(instr): jump_to = instr[i] + i instr[i] += (-1 if instr[i] >= 3 else 1) i = jump_to steps += 1
print "Steps to reach exit (part 2):", steps