part1 (3564B)
1--- Day 13: Transparent Origami --- 2 3You reach another volcanically active part of the cave. It would be nice if you could do some kind 4of thermal imaging so you could tell ahead of time which caves are too hot to safely enter. 5 6Fortunately, the submarine seems to be equipped with a thermal camera! When you activate it, you are 7greeted with: 8 9Congratulations on your purchase! To activate this infrared thermal imaging 10camera system, please enter the code found on page 1 of the manual. 11 12Apparently, the Elves have never used this feature. To your surprise, you manage to find the manual; 13as you go to open it, page 1 falls out. It's a large sheet of transparent paper! The transparent 14paper is marked with random dots and includes instructions on how to fold it up (your puzzle input). 15For example: 16 176,10 180,14 199,10 200,3 2110,4 224,11 236,0 246,12 254,1 260,13 2710,12 283,4 293,0 308,4 311,10 322,14 338,10 349,0 35 36fold along y=7 37fold along x=5 38 39The first section is a list of dots on the transparent paper. 0,0 represents the top-left 40coordinate. The first value, x, increases to the right. The second value, y, increases downward. 41So, the coordinate 3,0 is to the right of 0,0, and the coordinate 0,7 is below 0,0. The coordinates 42in this example form the following pattern, where # is a dot on the paper and . is an empty, 43unmarked position: 44 45...#..#..#. 46....#...... 47........... 48#.......... 49...#....#.# 50........... 51........... 52........... 53........... 54........... 55.#....#.##. 56....#...... 57......#...# 58#.......... 59#.#........ 60 61Then, there is a list of [1m[97mfold instructions[0m. Each instruction indicates a line on the transparent 62paper and wants you to fold the paper [1m[97mup[0m (for horizontal y=... lines) or [1m[97mleft[0m (for vertical x=... 63lines). In this example, the first fold instruction is fold along y=7, which designates the line 64formed by all of the positions where y is 7 (marked here with -): 65 66...#..#..#. 67....#...... 68........... 69#.......... 70...#....#.# 71........... 72........... 73----------- 74........... 75........... 76.#....#.##. 77....#...... 78......#...# 79#.......... 80#.#........ 81 82Because this is a horizontal line, fold the bottom half [1m[97mup[0m. Some of the dots might end up 83overlapping after the fold is complete, but dots will never appear exactly on a fold line. The 84result of doing this fold looks like this: 85 86#.##..#..#. 87#...#...... 88......#...# 89#...#...... 90.#.#..#.### 91........... 92........... 93 94Now, only 17 dots are visible. 95 96Notice, for example, the two dots in the bottom left corner before the transparent paper is folded; 97after the fold is complete, those dots appear in the top left corner (at 0,0 and 0,1). Because the 98paper is transparent, the dot just below them in the result (at 0,3) remains visible, as it can be 99seen through the transparent paper. 100 101Also notice that some dots can end up [1m[97moverlapping[0m; in this case, the dots merge together and become 102a single dot. 103 104The second fold instruction is fold along x=5, which indicates this line: 105 106#.##.|#..#. 107#...#|..... 108.....|#...# 109#...#|..... 110.#.#.|#.### 111.....|..... 112.....|..... 113 114Because this is a vertical line, fold [1m[97mleft[0m: 115 116##### 117#...# 118#...# 119#...# 120##### 121..... 122..... 123 124The instructions made a square! 125 126The transparent paper is pretty big, so for now, focus on just completing the first fold. After the 127first fold in the example above, [1m[97m17[0m dots are visible - dots that end up overlapping after the fold 128is completed count as a single dot. 129 130[1m[97mHow many dots are visible after completing just the first fold instruction on your transparent 131paper?[0m 132 133