[WIP] Solution to problem 8 part 1 in Python

This commit is contained in:
David Doblas Jiménez 2022-04-04 21:36:06 +02:00
parent 5d4145dcb4
commit be00c03840

21
src/Year_2017/P8.py Normal file
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)