|
| 1 | +--- Day 10: Monitoring Station --- |
| 2 | +---------------------------------- |
| 3 | + |
| 4 | +You fly into the asteroid belt and reach the Ceres monitoring station. |
| 5 | +The Elves here have an emergency: they're having trouble tracking all of |
| 6 | +the asteroids and can't be sure they're safe. |
| 7 | + |
| 8 | +The Elves would like to build a new monitoring station in a nearby area |
| 9 | +of space; they hand you a map of all of the asteroids in that region |
| 10 | +(your puzzle input). |
| 11 | + |
| 12 | +The map indicates whether each position is empty (`.`) or contains an |
| 13 | +asteroid (`#`). The asteroids are much smaller than they appear on the |
| 14 | +map, and every asteroid is exactly in the center of its marked position. |
| 15 | +The asteroids can be described with `X,Y` coordinates where `X` is the |
| 16 | +distance from the left edge and `Y` is the distance from the top edge |
| 17 | +(so the top-left corner is `0,0` and the position immediately to its |
| 18 | +right is `1,0`). |
| 19 | + |
| 20 | +Your job is to figure out which asteroid would be the best place to |
| 21 | +build a *new monitoring station*. A monitoring station can *detect* any |
| 22 | +asteroid to which it has *direct line of sight* - that is, there cannot |
| 23 | +be another asteroid *exactly* between them. This line of sight can be at |
| 24 | +any angle, not just lines aligned to the grid or |
| 25 | +[diagonally]{title="The Elves on Ceres are clearly not concerned with honor."}. |
| 26 | +The *best* location is the asteroid that can *detect* the largest number |
| 27 | +of other asteroids. |
| 28 | + |
| 29 | +For example, consider the following map: |
| 30 | + |
| 31 | + .#..# |
| 32 | + ..... |
| 33 | + ##### |
| 34 | + ....# |
| 35 | + ...## |
| 36 | + |
| 37 | +The best location for a new monitoring station on this map is the |
| 38 | +highlighted asteroid at `3,4` because it can detect `8` asteroids, more |
| 39 | +than any other location. (The only asteroid it cannot detect is the one |
| 40 | +at `1,0`; its view of this asteroid is blocked by the asteroid at |
| 41 | +`2,2`.) All other asteroids are worse locations; they can detect `7` or |
| 42 | +fewer other asteroids. Here is the number of other asteroids a |
| 43 | +monitoring station on each asteroid could detect: |
| 44 | + |
| 45 | + .7..7 |
| 46 | + ..... |
| 47 | + 67775 |
| 48 | + ....7 |
| 49 | + ...87 |
| 50 | + |
| 51 | +Here is an asteroid (`#`) and some examples of the ways its line of |
| 52 | +sight might be blocked. If there were another asteroid at the location |
| 53 | +of a capital letter, the locations marked with the corresponding |
| 54 | +lowercase letter would be blocked and could not be detected: |
| 55 | + |
| 56 | + #......... |
| 57 | + ...A...... |
| 58 | + ...B..a... |
| 59 | + .EDCG....a |
| 60 | + ..F.c.b... |
| 61 | + .....c.... |
| 62 | + ..efd.c.gb |
| 63 | + .......c.. |
| 64 | + ....f...c. |
| 65 | + ...e..d..c |
| 66 | + |
| 67 | +Here are some larger examples: |
| 68 | + |
| 69 | +- Best is `5,8` with `33` other asteroids detected: |
| 70 | + |
| 71 | + ......#.#. |
| 72 | + #..#.#.... |
| 73 | + ..#######. |
| 74 | + .#.#.###.. |
| 75 | + .#..#..... |
| 76 | + ..#....#.# |
| 77 | + #..#....#. |
| 78 | + .##.#..### |
| 79 | + ##...#..#. |
| 80 | + .#....#### |
| 81 | + |
| 82 | +- Best is `1,2` with `35` other asteroids detected: |
| 83 | + |
| 84 | + #.#...#.#. |
| 85 | + .###....#. |
| 86 | + .#....#... |
| 87 | + ##.#.#.#.# |
| 88 | + ....#.#.#. |
| 89 | + .##..###.# |
| 90 | + ..#...##.. |
| 91 | + ..##....## |
| 92 | + ......#... |
| 93 | + .####.###. |
| 94 | + |
| 95 | +- Best is `6,3` with `41` other asteroids detected: |
| 96 | + |
| 97 | + .#..#..### |
| 98 | + ####.###.# |
| 99 | + ....###.#. |
| 100 | + ..###.##.# |
| 101 | + ##.##.#.#. |
| 102 | + ....###..# |
| 103 | + ..#.#..#.# |
| 104 | + #..#.#.### |
| 105 | + .##...##.# |
| 106 | + .....#.#.. |
| 107 | + |
| 108 | +- Best is `11,13` with `210` other asteroids detected: |
| 109 | + |
| 110 | + .#..##.###...####### |
| 111 | + ##.############..##. |
| 112 | + .#.######.########.# |
| 113 | + .###.#######.####.#. |
| 114 | + #####.##.#.##.###.## |
| 115 | + ..#####..#.######### |
| 116 | + #################### |
| 117 | + #.####....###.#.#.## |
| 118 | + ##.################# |
| 119 | + #####.##.###..####.. |
| 120 | + ..######..##.####### |
| 121 | + ####.##.####...##..# |
| 122 | + .#####..#.######.### |
| 123 | + ##...#.##########... |
| 124 | + #.##########.####### |
| 125 | + .####.#.###.###.#.## |
| 126 | + ....##.##.###..##### |
| 127 | + .#.#.###########.### |
| 128 | + #.#.#.#####.####.### |
| 129 | + ###.##.####.##.#..## |
| 130 | + |
| 131 | +Find the best location for a new monitoring station. *How many other |
| 132 | +asteroids can be detected from that location?* |
| 133 | + |
| 134 | +Your puzzle answer was `214`. |
| 135 | + |
| 136 | +The first half of this puzzle is complete! It provides one gold star: \* |
| 137 | + |
| 138 | +--- Part Two --- {#part2} |
| 139 | +---------------- |
| 140 | + |
| 141 | +Once you give them the coordinates, the Elves quickly deploy an Instant |
| 142 | +Monitoring Station to the location and discover [the |
| 143 | +worst]{title="The Elves on Ceres just have a unique system of values, that's all."}: |
| 144 | +there are simply too many asteroids. |
| 145 | + |
| 146 | +The only solution is *complete vaporization by giant laser*. |
| 147 | + |
| 148 | +Fortunately, in addition to an asteroid scanner, the new monitoring |
| 149 | +station also comes equipped with a giant rotating laser perfect for |
| 150 | +vaporizing asteroids. The laser starts by pointing *up* and always |
| 151 | +rotates *clockwise*, vaporizing any asteroid it hits. |
| 152 | + |
| 153 | +If multiple asteroids are *exactly* in line with the station, the laser |
| 154 | +only has enough power to vaporize *one* of them before continuing its |
| 155 | +rotation. In other words, the same asteroids that can be *detected* can |
| 156 | +be vaporized, but if vaporizing one asteroid makes another one |
| 157 | +detectable, the newly-detected asteroid won't be vaporized until the |
| 158 | +laser has returned to the same position by rotating a full 360 degrees. |
| 159 | + |
| 160 | +For example, consider the following map, where the asteroid with the new |
| 161 | +monitoring station (and laser) is marked `X`: |
| 162 | + |
| 163 | + .#....#####...#.. |
| 164 | + ##...##.#####..## |
| 165 | + ##...#...#.#####. |
| 166 | + ..#.....X...###.. |
| 167 | + ..#.#.....#....## |
| 168 | + |
| 169 | +The first nine asteroids to get vaporized, in order, would be: |
| 170 | + |
| 171 | + .#....###24...#.. |
| 172 | + ##...##.13#67..9# |
| 173 | + ##...#...5.8####. |
| 174 | + ..#.....X...###.. |
| 175 | + ..#.#.....#....## |
| 176 | + |
| 177 | +Note that some asteroids (the ones behind the asteroids marked `1`, `5`, |
| 178 | +and `7`) won't have a chance to be vaporized until the next full |
| 179 | +rotation. The laser continues rotating; the next nine to be vaporized |
| 180 | +are: |
| 181 | + |
| 182 | + .#....###.....#.. |
| 183 | + ##...##...#.....# |
| 184 | + ##...#......1234. |
| 185 | + ..#.....X...5##.. |
| 186 | + ..#.9.....8....76 |
| 187 | + |
| 188 | +The next nine to be vaporized are then: |
| 189 | + |
| 190 | + .8....###.....#.. |
| 191 | + 56...9#...#.....# |
| 192 | + 34...7........... |
| 193 | + ..2.....X....##.. |
| 194 | + ..1.............. |
| 195 | + |
| 196 | +Finally, the laser completes its first full rotation (`1` through `3`), |
| 197 | +a second rotation (`4` through `8`), and vaporizes the last asteroid |
| 198 | +(`9`) partway through its third rotation: |
| 199 | + |
| 200 | + ......234.....6.. |
| 201 | + ......1...5.....7 |
| 202 | + ................. |
| 203 | + ........X....89.. |
| 204 | + ................. |
| 205 | + |
| 206 | +In the large example above (the one with the best monitoring station |
| 207 | +location at `11,13`): |
| 208 | + |
| 209 | +- The 1st asteroid to be vaporized is at `11,12`. |
| 210 | +- The 2nd asteroid to be vaporized is at `12,1`. |
| 211 | +- The 3rd asteroid to be vaporized is at `12,2`. |
| 212 | +- The 10th asteroid to be vaporized is at `12,8`. |
| 213 | +- The 20th asteroid to be vaporized is at `16,0`. |
| 214 | +- The 50th asteroid to be vaporized is at `16,9`. |
| 215 | +- The 100th asteroid to be vaporized is at `10,16`. |
| 216 | +- The 199th asteroid to be vaporized is at `9,6`. |
| 217 | +- *The 200th asteroid to be vaporized is at `8,2`.* |
| 218 | +- The 201st asteroid to be vaporized is at `10,9`. |
| 219 | +- The 299th and final asteroid to be vaporized is at `11,1`. |
| 220 | + |
| 221 | +The Elves are placing bets on which will be the *200th* asteroid to be |
| 222 | +vaporized. Win the bet by determining which asteroid that will be; *what |
| 223 | +do you get if you multiply its X coordinate by `100` and then add its Y |
| 224 | +coordinate?* (For example, `8,2` becomes *`802`*.) |
| 225 | + |
| 226 | +Although it hasn't changed, you can still [get your puzzle |
| 227 | +input](10/input). |
| 228 | + |
| 229 | +Answer: |
| 230 | + |
| 231 | +You can also [\[Share[on |
| 232 | +[Twitter](https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Monitoring+Station%22+%2D+Day+10+%2D+Advent+of+Code+2019&url=https%3A%2F%2Fadventofcode%2Ecom%2F2019%2Fday%2F10&related=ericwastl&hashtags=AdventOfCode) |
| 233 | +[Mastodon](javascript:void(0);)]{.share-content}\]]{.share} this puzzle. |
0 commit comments