34 lines
804 B
Python
34 lines
804 B
Python
from aoc import AOCDay
|
|
from typing import Any
|
|
|
|
from intcode import IntCode
|
|
|
|
|
|
class Day(AOCDay):
|
|
test_solutions_p1 = [100, 2, 2, 2, 30]
|
|
test_solutions_p2 = []
|
|
|
|
def part1(self) -> Any:
|
|
memory = self.getInputAsArraySplit(',', int)
|
|
memory[1] = 12
|
|
memory[2] = 2
|
|
comp = IntCode(memory, 100)
|
|
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
|