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/day7.py

30 lines
788 B

import unittest
import os
from . import comp
import itertools
class Day7(unittest.TestCase):
def get_code(self):
inputfile = os.path.join(os.path.dirname(__file__), "input/day7_input")
with open(inputfile) as fp:
return [int(k) for k in fp.readline().split(',')]
def test_day7a(self):
com = comp.OpcodeComputer(self.get_code())
configs = itertools.permutations(range(5), 5)
res = 0
out = []
for conf in configs:
sig = 0
for phase in conf:
out.clear()
com.process_op([phase, sig], out)
sig = out[0]
res = int(out[0]) if int(out[0]) > res else res
self.assertEqual(res, 21000)
def test_day7b(self):
pass