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.
27 lines
878 B
27 lines
878 B
import unittest
|
|
import os
|
|
from .comp import OpcodeComputer
|
|
|
|
|
|
class Day2(unittest.TestCase):
|
|
inputfile = os.path.join(os.path.dirname(__file__), "input/day2_input")
|
|
|
|
def test_day2a(self):
|
|
with open(self.inputfile) as fp:
|
|
code = [int(k) for k in fp.readline().split(',')]
|
|
code[1] = 12
|
|
code[2] = 2
|
|
self.assertEqual(OpcodeComputer().process_op(code), 5098658)
|
|
|
|
def test_day2b(self):
|
|
with open(self.inputfile) as fp:
|
|
file_code = [int(k) for k in fp.readline().split(',')]
|
|
for a, b in [(x, y) for x in range(55) for y in range(70)]:
|
|
code = list(file_code)
|
|
code[1] = a
|
|
code[2] = b
|
|
|
|
result = OpcodeComputer().process_op(code)
|
|
if result == 19690720:
|
|
break
|
|
self.assertEqual(100 * a + b, 5064)
|
|
|