-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathday_08a.py
More file actions
30 lines (26 loc) · 744 Bytes
/
day_08a.py
File metadata and controls
30 lines (26 loc) · 744 Bytes
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
#!/usr/bin/env python3
def main():
f = open("../input/day_08_input")
lines = [line.strip().replace("\n", "").replace("\r", "") for line in f]
n_lines = len(lines)
execed_list = [False] * n_lines
line = 0
acc = 0
while line < n_lines:
if execed_list[line]:
print(acc)
return acc
else:
execed_list[line] = True
if lines[line][0:3] == "nop":
line = line + 1
elif lines[line][0:3] == "jmp":
line = line + int(lines[line][3:])
elif lines[line][0:3] == "acc":
acc += int(lines[line][3:])
line = line + 1
else:
print("WTH")
return 0
if __name__ == "__main__":
main()