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.
AdventOfCode19/days/day2.py

30 lines
967 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):
with open(self.inputfile) as fp:
code: List[int] = [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: List[int] = [int(k) for k in fp.readline().split(',')]
a: int = 0
b: int = 0
for a, b in [(x, y) for x in range(100) for y in range(100)]:
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)