mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Implement 2019 day 13 part 1
This commit is contained in:
20
2019/aoc2019/day13.py
Normal file
20
2019/aoc2019/day13.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from typing import TextIO
|
||||||
|
|
||||||
|
from aoc2019.intcode import Computer, read_program
|
||||||
|
|
||||||
|
|
||||||
|
def part1(data: TextIO) -> int:
|
||||||
|
computer = Computer(read_program(data))
|
||||||
|
|
||||||
|
computer.run()
|
||||||
|
|
||||||
|
screen = {}
|
||||||
|
|
||||||
|
while computer.output:
|
||||||
|
x = computer.output.popleft()
|
||||||
|
y = computer.output.popleft()
|
||||||
|
val = computer.output.popleft()
|
||||||
|
|
||||||
|
screen[x, y] = val
|
||||||
|
|
||||||
|
return sum(1 for val in screen.values() if val == 2)
|
||||||
Reference in New Issue
Block a user