[WIP] Solution to problem 8 part 1 in Python

This commit is contained in:
daviddoji committed 2022-04-04 21:36:06 +02:00
1 parent 5d4145dcb4
commit be00c03840
1 file changed
+21
+21
View File
@@ -0,0 +1,21 @@
from collections import defaultdict
with open("files/P8.txt") as f:
instructions = [line for line in f.read().strip().split("\n")]
# print(instructions)
registry: dict[str, int] = defaultdict(int)
def inc(s: str) -> None:
reg, inst, num, iff, reg_cond, op, num_cond = s.split()
if eval("registry[reg_cond] " + op + num_cond):
registry[reg] += int(num)
for instruction in instructions:
inc(instruction)
break
print(registry)