mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Fix day 8 to paint front-to-back
This commit is contained in:
@@ -24,10 +24,11 @@ def format_row(row: Iterable[int]) -> str:
|
||||
|
||||
|
||||
def part2(data: TextIO) -> str:
|
||||
layers = list(parse_layers(25, 6, data))
|
||||
background = numpy.zeros(25 * 6, numpy.int8)
|
||||
background.fill(2)
|
||||
|
||||
for layer in reversed(layers):
|
||||
background[layer != 2] = layer[layer != 2]
|
||||
for layer in parse_layers(25, 6, data):
|
||||
mask = background == 2
|
||||
background[mask] = layer[mask]
|
||||
|
||||
return '\n'.join(format_row(row) for row in background.reshape(6, 25))
|
||||
|
||||
Reference in New Issue
Block a user