[WIP] Solution to problem 8 part 1 in Python
This commit is contained in:
parent
5d4145dcb4
commit
be00c03840
21
src/Year_2017/P8.py
Normal file
21
src/Year_2017/P8.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user