-
Notifications
You must be signed in to change notification settings - Fork 0
/
day8_1.py
30 lines (27 loc) · 862 Bytes
/
day8_1.py
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
28
29
30
class Day8_1:
input = """"""
def __init__(self):
acc = 0
instructions = self.input.split('\n')
visited_indexes = set()
i = 0
current_instruction = instructions[i]
while True:
if i in visited_indexes:
print(acc)
break
inst, nr = current_instruction.split(' ')
if inst == "acc":
acc += int(nr)
visited_indexes.add(i)
i += 1
current_instruction = instructions[i]
elif inst == "nop":
visited_indexes.add(i)
i += 1
current_instruction = instructions[i]
elif inst == "jmp":
visited_indexes.add(i)
i += int(nr)
current_instruction = instructions[i]
Day8_1()