Fix day 8 to paint front-to-back

This commit is contained in:
2021-01-24 10:22:37 +01:00
parent b65c805891
commit 091c125f42

View File

@@ -24,10 +24,11 @@ def format_row(row: Iterable[int]) -> str:
def part2(data: TextIO) -> str: def part2(data: TextIO) -> str:
layers = list(parse_layers(25, 6, data))
background = numpy.zeros(25 * 6, numpy.int8) background = numpy.zeros(25 * 6, numpy.int8)
background.fill(2)
for layer in reversed(layers): for layer in parse_layers(25, 6, data):
background[layer != 2] = layer[layer != 2] mask = background == 2
background[mask] = layer[mask]
return '\n'.join(format_row(row) for row in background.reshape(6, 25)) return '\n'.join(format_row(row) for row in background.reshape(6, 25))