mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
2019 day 19 part 2
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import copy
|
||||
from itertools import product
|
||||
import itertools
|
||||
from collections import deque
|
||||
from typing import TextIO, Tuple
|
||||
|
||||
from aoc2019.intcode import Computer, read_program
|
||||
@@ -43,3 +44,23 @@ def part1(data: TextIO) -> int:
|
||||
total += min(x_max, 49) - min(x_min, 50) + 1
|
||||
|
||||
return total
|
||||
|
||||
|
||||
def part2(data: TextIO) -> int:
|
||||
computer = Computer(read_program(data))
|
||||
|
||||
x_min, x_max = (0, 0)
|
||||
|
||||
lines = deque()
|
||||
|
||||
for y in itertools.count():
|
||||
x_min, x_max = find_line(y, x_min, x_max, computer)
|
||||
lines.append((x_min, x_max))
|
||||
|
||||
if len(lines) == 100:
|
||||
x_top_min, x_top_max = lines.popleft()
|
||||
|
||||
if x_top_max - x_min + 1 < 100:
|
||||
continue
|
||||
|
||||
return x_min * 10000 + y - 99
|
||||
|
||||
Reference in New Issue
Block a user