from intcode import IntCode from tools.aoc import AOCDay from typing import Any class Day(AOCDay): inputs = [ [ (100, "test_input02"), (2, "test_input02_2"), (2, "test_input02_3"), (2, "test_input02_4"), (30, "test_input02_5"), (3760627, "input02") ], [ (7195, "input02") ] ] def part1(self) -> Any: memory = self.getInputAsArraySplit(',', int) memory[1] = 12 memory[2] = 2 comp = IntCode(memory) comp.run() return comp.memory[0] def part2(self) -> Any: init_memory = self.getInputAsArraySplit(",", int) for x in range(100): for y in range(100): memory = init_memory.copy() memory[1] = x memory[2] = y comp = IntCode(memory) comp.run() if comp.memory[0] == 19690720: return 100 * x + y return -1 if __name__ == '__main__': day = Day(2019, 2) day.run(verbose=True)