summaryrefslogtreecommitdiffstats
path: root/2020/day8/handheld.py
blob: 6197a2ff15d53d49460568000d6b3af90b69673d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
boot_code = list()
with open("input", "r") as file:
    for line in file:
        line = line.strip()
        oparg = line.split(" ")
        boot_code.append((oparg[0], int(oparg[1])))


cursor = 0

accumulator = 0

sofar = set()

while cursor not in sofar:
    sofar.add(cursor)

    if boot_code[cursor][0] == "acc":
        accumulator += boot_code[cursor][1]
    elif boot_code[cursor][0] == "jmp":
        cursor += boot_code[cursor][1] - 1
    else:
        pass

    cursor += 1

print(accumulator)