diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:18:18 -0400 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:19:39 -0400 |
| commit | 87ab487d59fa85dbe2afa55cc841b02805ae42ca (patch) | |
| tree | cd90ab715e1b5b5803674045dbafd6d51d27ac90 /src/08/part2 | |
| parent | 1bcc82c5bfbde87edd03c01ffdf9ee5934681592 (diff) | |
| download | aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.tar.gz aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.zip | |
Reorder days into src
Diffstat (limited to 'src/08/part2')
| -rw-r--r-- | src/08/part2 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/08/part2 b/src/08/part2 new file mode 100644 index 0000000..7c88e38 --- /dev/null +++ b/src/08/part2 @@ -0,0 +1,46 @@ +--- Part Two --- + +Now you're ready to decode the image. The image is rendered by stacking the layers and aligning the +pixels with the same positions in each layer. The digits indicate the color of the corresponding +pixel: 0 is black, 1 is white, and 2 is transparent. + +The layers are rendered with the first layer in front and the last layer in back. So, if a given +position has a transparent pixel in the first and second layers, a black pixel in the third layer, +and a white pixel in the fourth layer, the final image would have a [1m[97mblack[0m pixel at that position. + +For example, given an image 2 pixels wide and 2 pixels tall, the image data 0222112222120000 +corresponds to the following image layers: + +Layer 1: [1m[97m0[0m2 + 22 + +Layer 2: 1[1m[97m1[0m + 22 + +Layer 3: 22 + [1m[97m1[0m2 + +Layer 4: 00 + 0[1m[97m0[0m + +Then, the full image can be found by determining the top visible pixel in each position: + + + - The top-left pixel is [1m[97mblack[0m because the top layer is 0. + + - The top-right pixel is [1m[97mwhite[0m because the top layer is 2 (transparent), but the second layer is 1. + + - The bottom-left pixel is [1m[97mwhite[0m because the top two layers are 2, but the third layer is 1. + + - The bottom-right pixel is [1m[97mblack[0m because the only visible pixel in that position is 0 (from layer +4). + + +So, the final image looks like this: + +01 +10 + +[1m[97mWhat message is produced after decoding your image?[0m + + |
