2019 day 9

This commit is contained in:
2025-08-01 17:35:51 +02:00
parent f705cf64fe
commit 854d0b51fb
5 changed files with 185 additions and 77 deletions

20
2019/day9/day9.py Normal file
View File

@@ -0,0 +1,20 @@
# TODO replace PYTHONPATH hack with a proper solution, like making intcode an
# installed module https://stackoverflow.com/a/50194143
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).absolute().parent.parent / "intcode"))
from intcode import interpret_intcode, Interpreter
def main(inp):
mem = list(map(int, inp.readline().rstrip().split(",")))
print("Part 1: ", interpret_intcode(mem[::], stdin=[1]).stdout[0])
print("Part 2: ", interpret_intcode(mem[::], stdin=[2]).stdout[0])
if __name__ == "__main__":
import fileinput
main(fileinput.input())