advent-of-code/2019-python/output/day_05.py
Anders Ytterström 9eccd731b4 Solve 2019:05 "Sunny with a Chance of Asteroids"
Refactored the intcode computer to live in a separate
file, since it will come back more times.

As a nice touch, output of aoc.py will print the version
used of the intcode.

As another nice touch, the int code has a CHANGELOG.
2023-12-19 14:51:11 +01:00

29 lines
614 B
Python

from output import answer, puzzleinput
from output.intcode_computer import execute
n = 5
title = "Sunny with a Chance of Asteroids"
@puzzleinput(n)
def parse_input(data):
return list(map(int, data.split(",")))
@answer(1, "[intcode-0.2.0] Program diagnostic code, ID 1: {}")
def part_1(program):
_, stdout = execute(program, stdin=1)
return max(stdout)
@answer(2, "[intcode-0.2.1] Program diagnostic code, ID 5: {}")
def part_2(program):
_, stdout = execute(program, stdin=5)
return stdout[0]
if __name__ == "__main__":
parsed = parse_input()
part_1(parsed)
part_2(parsed)