You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
644 B
29 lines
644 B
import os
|
|
|
|
from . import OpcodeComputer
|
|
|
|
|
|
inputfile = os.path.join(os.path.dirname(__file__), "input/day2_input")
|
|
|
|
|
|
def test_day2a():
|
|
comp = OpcodeComputer(inputfile)
|
|
comp.memory[1] = 12
|
|
comp.memory[2] = 2
|
|
|
|
assert comp.process_all() == 5098658
|
|
|
|
|
|
def test_day2b():
|
|
comp = OpcodeComputer(inputfile)
|
|
a: int = 0
|
|
b: int = 0
|
|
for a, b in [(x, y) for x in range(100) for y in range(100)]:
|
|
comp.reset()
|
|
comp.memory[1] = int(a)
|
|
comp.memory[2] = int(b)
|
|
|
|
result = comp.process_all()
|
|
if result == 19690720:
|
|
break
|
|
assert 100 * a + b == 5064
|
|
|