General Discussions

Advent of Code - Base A Style! (Post 8 of 26)

14 - Magnetar
14 - Magnetar

Giving up on the Intcode in challenge 7 because honestly, I'm not understanding the instructions.

 

So onto 8.....

 

Day 8 - Space Image Format

 

0.9 seconds

 

A fun, non-Intcode challenge! Here we need to decipher messages, given the coordinates of points along "layers"

Puzzle input looks a little crazy - 

EstherB47_0-1577124766736.png

But, instructions are clear. We have an image here that's 25 pixels wide by 6 pixels tall, so I need to chunk the data into rows of 150 characters (25*6). Easily done with a Regex Parse tool

 

For part 1, need to count the numbers of zeros, ones, and twos. Easily done with a Regex_CountMatches function:

 

REGEX_CountMatches([Field1],"0"). etc.

To get the multiple of the numbers of ones multiplied by the numbers of twos, a simple multiplication works. Sort descending to find the answer.

EstherB47_1-1577126452199.png



Part 2 is figuring out the message. Stack up all of the layers. 0 is black, 1 is white, and 2 is transparent. So, whichever is showing in the stack is the color used.

Another Regex parse tool separates each row into individual letters. I love to use the Tile tool to number within a group (Unique value method on the Record ID field). Then a summarize tool finds the first position of each 0, 1, or 2 within each position in the layers. Next, filter out the transparent values (where Field1 = 2). Sort and pick out the first character (a 0 or 1) in each position in the message. There are 150, which checks out with 25*6. Now rebuild the picture with a Make Columns tool. Sometimes I prefer this to Crosstab. Here's the configuration:

EstherB47_3-1577127482218.png

Added a Browse, and realized this was REALLY hard to read. Decided to replace 0s with empty values, and 1s with #s. Added a Table tool (massive props to @CharlieS for sharing his vast knowledge of Reporting tools with our community!!) with a fixed width of 1". And voila!

EstherB47_4-1577128060614.png



Cheers!

Esther