diff options
Diffstat (limited to 'src/20/part1')
| -rw-r--r-- | src/20/part1 | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/src/20/part1 b/src/20/part1 new file mode 100644 index 0000000..9b3cc8c --- /dev/null +++ b/src/20/part1 @@ -0,0 +1,183 @@ +--- Day 20: Jurassic Jigsaw --- + +The high-speed train leaves the forest and quickly carries you south. You can even see a desert in +the distance! Since you have some spare time, you might as well see if there was anything +interesting in the image the Mythical Information Bureau satellite captured. + +After decoding the satellite messages, you discover that the data actually contains many small +images created by the satellite's [1m[37mcamera array[0m. The camera array consists of many +cameras; rather than produce a single square image, they produce many smaller square image +[1m[37mtiles[0m that need to be [1m[37mreassembled back into a single image[0m. + +Each camera in the camera array returns a single monochrome [1m[37mimage tile[0m with a random +unique [1m[37mID number[0m. The tiles (your puzzle input) arrived in a random order. + +Worse yet, the camera array appears to be malfunctioning: each image tile has been [1m[37mrotated +and flipped to a random orientation[0m. Your first task is to reassemble the original image by +orienting the tiles so they fit together. + +To show how the tiles should be reassembled, each tile's image data includes a border that should +line up exactly with its adjacent tiles. All tiles have this border, and the border lines up exactly +when the tiles are both oriented correctly. Tiles at the edge of the image also have this border, +but the outermost edges won't line up with any other tiles. + +For example, suppose you have the following nine tiles: + +Tile 2311: +..##.#..#. +##..#..... +#...##..#. +####.#...# +##.##.###. +##...#.### +.#.#.#..## +..#....#.. +###...#.#. +..###..### + +Tile 1951: +#.##...##. +#.####...# +.....#..## +#...###### +.##.#....# +.###.##### +###.##.##. +.###....#. +..#.#..#.# +#...##.#.. + +Tile 1171: +####...##. +#..##.#..# +##.#..#.#. +.###.####. +..###.#### +.##....##. +.#...####. +#.##.####. +####..#... +.....##... + +Tile 1427: +###.##.#.. +.#..#.##.. +.#.##.#..# +#.#.#.##.# +....#...## +...##..##. +...#.##### +.#.####.#. +..#..###.# +..##.#..#. + +Tile 1489: +##.#.#.... +..##...#.. +.##..##... +..#...#... +#####...#. +#..#.#.#.# +...#.#.#.. +##.#...##. +..##.##.## +###.##.#.. + +Tile 2473: +#....####. +#..#.##... +#.##..#... +######.#.# +.#...#.#.# +.######### +.###.#..#. +########.# +##...##.#. +..###.#.#. + +Tile 2971: +..#.#....# +#...###... +#.#.###... +##.##..#.. +.#####..## +.#..####.# +#..#.#..#. +..####.### +..#.#.###. +...#.#.#.# + +Tile 2729: +...#.#.#.# +####.#.... +..#.#..... +....#..#.# +.##..##.#. +.#.####... +####.#.#.. +##.####... +##..#.##.. +#.##...##. + +Tile 3079: +#.#.#####. +.#..###### +..#....... +######.... +####.#..#. +.#...#.##. +#.#####.## +..#.###... +..#....... +..#.###... + +By rotating, flipping, and rearranging them, you can find a square arrangement that causes all +adjacent borders to line up: + +#...##.#.. ..###..### #.#.#####. +..#.#..#.# ###...#.#. .#..###### +.###....#. ..#....#.. ..#....... +###.##.##. .#.#.#..## ######.... +.###.##### ##...#.### ####.#..#. +.##.#....# ##.##.###. .#...#.##. +#...###### ####.#...# #.#####.## +.....#..## #...##..#. ..#.###... +#.####...# ##..#..... ..#....... +#.##...##. ..##.#..#. ..#.###... + +#.##...##. ..##.#..#. ..#.###... +##..#.##.. ..#..###.# ##.##....# +##.####... .#.####.#. ..#.###..# +####.#.#.. ...#.##### ###.#..### +.#.####... ...##..##. .######.## +.##..##.#. ....#...## #.#.#.#... +....#..#.# #.#.#.##.# #.###.###. +..#.#..... .#.##.#..# #.###.##.. +####.#.... .#..#.##.. .######... +...#.#.#.# ###.##.#.. .##...#### + +...#.#.#.# ###.##.#.. .##...#### +..#.#.###. ..##.##.## #..#.##..# +..####.### ##.#...##. .#.#..#.## +#..#.#..#. ...#.#.#.. .####.###. +.#..####.# #..#.#.#.# ####.###.. +.#####..## #####...#. .##....##. +##.##..#.. ..#...#... .####...#. +#.#.###... .##..##... .####.##.# +#...###... ..##...#.. ...#..#### +..#.#....# ##.#.#.... ...##..... + +For reference, the IDs of the above tiles are: + +[1m[37m1951[0m 2311 [1m[37m3079[0m +2729 1427 2473 +[1m[37m2971[0m 1489 [1m[37m1171[0m + +To check that you've assembled the image correctly, multiply the IDs of the four corner tiles +together. If you do this with the assembled tiles from the example above, you get 1951 * 3079 * 2971 +* 1171 = [1m[37m20899048083289[0m. + +Assemble the tiles into an image. [1m[37mWhat do you get if you multiply together the IDs of the +four corner tiles?[0m + + |
