From 4bb6f8d06c0e384f3394012b1d48da58ed28cc5e Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 12 Dec 2021 01:24:32 +0300 Subject: 2020, tracking --- 2020/day8/handheld.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2020/day8/handheld.py (limited to '2020/day8/handheld.py') 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 @@ +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) -- cgit v1.2.3-70-g09d2