Solution to problem 8 in Python
This commit is contained in:
parent
46d51b8548
commit
7ec3bd29d6
@ -121,15 +121,16 @@ def part_2() -> None:
|
|||||||
if layer[pixel] == 2:
|
if layer[pixel] == 2:
|
||||||
continue
|
continue
|
||||||
full_image.append(layer[pixel])
|
full_image.append(layer[pixel])
|
||||||
|
# only grab the first non-transparent pixel
|
||||||
break
|
break
|
||||||
|
|
||||||
for idx, pixel in enumerate(full_image):
|
for idx, pixel in enumerate(full_image):
|
||||||
|
# only black (0) and white (1) pixels are in the full image
|
||||||
if pixel == 0:
|
if pixel == 0:
|
||||||
print(" ", end="")
|
print(" ", end="")
|
||||||
elif pixel == 1:
|
elif pixel == 1:
|
||||||
print("X", end="")
|
print("X", end="")
|
||||||
elif pixel == 2:
|
# wrap around image's width (25 pixels)
|
||||||
print("o", end="")
|
|
||||||
if (idx + 1) % 25 == 0:
|
if (idx + 1) % 25 == 0:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user