diff --git a/src/Year_2017/P8.py b/src/Year_2017/P8.py new file mode 100644 index 0000000..4ddf353 --- /dev/null +++ b/src/Year_2017/P8.py @@ -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)