aoc2020/8/1.py

19 lines
329 B
Python
Raw Normal View History

2020-12-09 09:26:04 +01:00
with open("input") as f:
program = [x.strip() for x in f]
ip = 0
acc = 0
executed = []
while True:
if ip in executed:
break
inst, count = program[ip].split(" ")
executed.append(ip)
ip += 1
if inst == "acc":
acc += int(count)
if inst == "jmp":
ip += int(count) - 1
print(acc)