mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 05:40:32 +01:00
Implement 2019 day 5 part 1
This commit is contained in:
29
2019/aoc2019/day05.py
Normal file
29
2019/aoc2019/day05.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import TextIO
|
||||
|
||||
from aoc2019.intcode import read_program, Computer
|
||||
|
||||
|
||||
def part1(data: TextIO) -> int:
|
||||
program = read_program(data)
|
||||
|
||||
computer = Computer(program)
|
||||
|
||||
# Enter the required starting code
|
||||
computer.input.append(1)
|
||||
|
||||
computer.run()
|
||||
|
||||
return computer.output.pop()
|
||||
|
||||
|
||||
def part2(data: TextIO) -> int:
|
||||
program = read_program(data)
|
||||
|
||||
computer = Computer(program)
|
||||
|
||||
# Enter the required starting code
|
||||
computer.input.append(5)
|
||||
|
||||
computer.run()
|
||||
|
||||
return computer.output.pop()
|
||||
Reference in New Issue
Block a user