diff --git a/days/test_day13.py b/days/test_day13.py index 1d32beb..9b0f310 100644 --- a/days/test_day13.py +++ b/days/test_day13.py @@ -2,7 +2,6 @@ import os from .comp import OpcodeComputer - inputfile = os.path.join(os.path.dirname(__file__), "input/day13_input") @@ -13,3 +12,24 @@ def test_day13a(): comp.__next__() res += 1 if comp.__next__() == 2 else 0 assert res == 309 + + +def test_day13b(): + dir = 0 + pipe = iter(lambda: dir, 2) + comp = OpcodeComputer(inputfile) + comp.memory[0] = 2 + proc = comp.process_op(pipe) + score = 0 + padx = 0 + for x in proc: + y = proc.__next__() + c = proc.__next__() + if c == 4: + dir = -1 if padx > x else 1 if padx < x else 0 + padx += dir + elif c == 3: + padx = x + elif x == -1 and y == 0: + score = c + assert score == 15410