description.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. --- Day 16: The Floor Will Be Lava ---
  2. With the beam of light completely focused somewhere, the reindeer leads you deeper still into the Lava Production Facility. At some point, you realize that the steel facility walls have been replaced with cave, and the doorways are just cave, and the floor is cave, and you're pretty sure this is actually just a giant cave.
  3. Finally, as you approach what must be the heart of the mountain, you see a bright light in a cavern up ahead. There, you discover that the beam of light you so carefully focused is emerging from the cavern wall closest to the facility and pouring all of its energy into a contraption on the opposite side.
  4. Upon closer inspection, the contraption appears to be a flat, two-dimensional square grid containing empty space (.), mirrors (/ and \), and splitters (| and -).
  5. The contraption is aligned so that most of the beam bounces around the grid, but each tile on the grid converts some of the beam's light into heat to melt the rock in the cavern.
  6. You note the layout of the contraption (your puzzle input). For example:
  7. .|...\....
  8. |.-.\.....
  9. .....|-...
  10. ........|.
  11. ..........
  12. .........\
  13. ..../.\\..
  14. .-.-/..|..
  15. .|....-|.\
  16. ..//.|....
  17. The beam enters in the top-left corner from the left and heading to the right. Then, its behavior depends on what it encounters as it moves:
  18. If the beam encounters empty space (.), it continues in the same direction.
  19. If the beam encounters a mirror (/ or \), the beam is reflected 90 degrees depending on the angle of the mirror. For instance, a rightward-moving beam that encounters a / mirror would continue upward in the mirror's column, while a rightward-moving beam that encounters a \ mirror would continue downward from the mirror's column.
  20. If the beam encounters the pointy end of a splitter (| or -), the beam passes through the splitter as if the splitter were empty space. For instance, a rightward-moving beam that encounters a - splitter would continue in the same direction.
  21. If the beam encounters the flat side of a splitter (| or -), the beam is split into two beams going in each of the two directions the splitter's pointy ends are pointing. For instance, a rightward-moving beam that encounters a | splitter would split into two beams: one that continues upward from the splitter's column and one that continues downward from the splitter's column.
  22. Beams do not interact with other beams; a tile can have many beams passing through it at the same time. A tile is energized if that tile has at least one beam pass through it, reflect in it, or split in it.
  23. In the above example, here is how the beam of light bounces around the contraption:
  24. >|<<<\....
  25. |v-.\^....
  26. .v...|->>>
  27. .v...v^.|.
  28. .v...v^...
  29. .v...v^..\
  30. .v../2\\..
  31. <->-/vv|..
  32. .|<<<2-|.\
  33. .v//.|.v..
  34. Beams are only shown on empty tiles; arrows indicate the direction of the beams. If a tile contains beams moving in multiple directions, the number of distinct directions is shown instead. Here is the same diagram but instead only showing whether a tile is energized (#) or not (.):
  35. ######....
  36. .#...#....
  37. .#...#####
  38. .#...##...
  39. .#...##...
  40. .#...##...
  41. .#..####..
  42. ########..
  43. .#######..
  44. .#...#.#..
  45. Ultimately, in this example, 46 tiles become energized.
  46. The light isn't energizing enough tiles to produce lava; to debug the contraption, you need to start by analyzing the current situation. With the beam starting in the top-left heading right, how many tiles end up being energized?
  47. Your puzzle answer was 6795.
  48. --- Part Two ---
  49. As you try to work out what might be wrong, the reindeer tugs on your shirt and leads you to a nearby control panel. There, a collection of buttons lets you align the contraption so that the beam enters from any edge tile and heading away from that edge. (You can choose either of two directions for the beam if it starts on a corner; for instance, if the beam starts in the bottom-right corner, it can start heading either left or upward.)
  50. So, the beam could start on any tile in the top row (heading downward), any tile in the bottom row (heading upward), any tile in the leftmost column (heading right), or any tile in the rightmost column (heading left). To produce lava, you need to find the configuration that energizes as many tiles as possible.
  51. In the above example, this can be achieved by starting the beam in the fourth tile from the left in the top row:
  52. .|<2<\....
  53. |v-v\^....
  54. .v.v.|->>>
  55. .v.v.v^.|.
  56. .v.v.v^...
  57. .v.v.v^..\
  58. .v.v/2\\..
  59. <-2-/vv|..
  60. .|<<<2-|.\
  61. .v//.|.v..
  62. Using this configuration, 51 tiles are energized:
  63. .#####....
  64. .#.#.#....
  65. .#.#.#####
  66. .#.#.##...
  67. .#.#.##...
  68. .#.#.##...
  69. .#.#####..
  70. ########..
  71. .#######..
  72. .#...#.#..
  73. Find the initial beam configuration that energizes the largest number of tiles; how many tiles are energized in that configuration?
  74. Your puzzle answer was 7154.
  75. Both parts of this puzzle are complete! They provide two gold stars: **