summaryrefslogtreecommitdiffstats
path: root/2020/day8/handheld.py
diff options
context:
space:
mode:
authorYigit Sever2021-12-12 01:24:32 +0300
committerYigit Sever2021-12-12 01:24:32 +0300
commit4bb6f8d06c0e384f3394012b1d48da58ed28cc5e (patch)
treed6478c85c0488a1059567ccd2882cb10039c2546 /2020/day8/handheld.py
parentae3853b6e8ab02023ccd74baac6dc177b1ee879a (diff)
downloadaoc-4bb6f8d06c0e384f3394012b1d48da58ed28cc5e.tar.gz
aoc-4bb6f8d06c0e384f3394012b1d48da58ed28cc5e.tar.bz2
aoc-4bb6f8d06c0e384f3394012b1d48da58ed28cc5e.zip
2020, tracking
Diffstat (limited to '2020/day8/handheld.py')
-rw-r--r--2020/day8/handheld.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/2020/day8/handheld.py b/2020/day8/handheld.py
new file mode 100644
index 0000000..6197a2f
--- /dev/null
+++ b/2020/day8/handheld.py
@@ -0,0 +1,27 @@
1boot_code = list()
2with open("input", "r") as file:
3 for line in file:
4 line = line.strip()
5 oparg = line.split(" ")
6 boot_code.append((oparg[0], int(oparg[1])))
7
8
9cursor = 0
10
11accumulator = 0
12
13sofar = set()
14
15while cursor not in sofar:
16 sofar.add(cursor)
17
18 if boot_code[cursor][0] == "acc":
19 accumulator += boot_code[cursor][1]
20 elif boot_code[cursor][0] == "jmp":
21 cursor += boot_code[cursor][1] - 1
22 else:
23 pass
24
25 cursor += 1
26
27print(accumulator)