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.
28 lines
822 B
28 lines
822 B
import unittest
|
|
import os
|
|
from typing import List
|
|
from .comp import OpcodeComputer
|
|
|
|
|
|
class Day2(unittest.TestCase):
|
|
inputfile = os.path.join(os.path.dirname(__file__), "input/day2_input")
|
|
|
|
def test_day2a(self):
|
|
comp = OpcodeComputer(self.inputfile)
|
|
comp.memory[1] = 12
|
|
comp.memory[2] = 2
|
|
self.assertEqual(comp.process_all(), 5098658)
|
|
|
|
def test_day2b(self):
|
|
comp = OpcodeComputer(self.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
|
|
self.assertEqual(100 * a + b, 5064)
|
|
|