advent2022

Advent of Code 2022 Solutions
git clone git://bsandro.tech/advent2022
Log | Files | Refs | README | LICENSE

task.txt (6207B)


      1 --- Day 17: Pyroclastic Flow ---
      2 
      3 Your handheld device has located an alternative exit from the cave for you and the elephants. The ground is rumbling almost continuously now, but the strange valves bought you some time. It's definitely getting warmer in here, though.
      4 
      5 The tunnels eventually open into a very tall, narrow chamber. Large, oddly-shaped rocks are falling into the chamber from above, presumably due to all the rumbling. If you can't work out where the rocks will fall next, you might be crushed!
      6 
      7 The five types of rocks have the following peculiar shapes, where # is rock and . is empty space:
      8 
      9 ####
     10 
     11 .#.
     12 ###
     13 .#.
     14 
     15 ..#
     16 ..#
     17 ###
     18 
     19 #
     20 #
     21 #
     22 #
     23 
     24 ##
     25 ##
     26 
     27 The rocks fall in the order shown above: first the - shape, then the + shape, and so on. Once the end of the list is reached, the same order repeats: the - shape falls first, sixth, 11th, 16th, etc.
     28 
     29 The rocks don't spin, but they do get pushed around by jets of hot gas coming out of the walls themselves. A quick scan reveals the effect the jets of hot gas will have on the rocks as they fall (your puzzle input).
     30 
     31 For example, suppose this was the jet pattern in your cave:
     32 
     33 >>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>
     34 
     35 In jet patterns, < means a push to the left, while > means a push to the right. The pattern above means that the jets will push a falling rock right, then right, then right, then left, then left, then right, and so on. If the end of the list is reached, it repeats.
     36 
     37 The tall, vertical chamber is exactly seven units wide. Each rock appears so that its left edge is two units away from the left wall and its bottom edge is three units above the highest rock in the room (or the floor, if there isn't one).
     38 
     39 After a rock appears, it alternates between being pushed by a jet of hot gas one unit (in the direction indicated by the next symbol in the jet pattern) and then falling one unit down. If any movement would cause any part of the rock to move into the walls, floor, or a stopped rock, the movement instead does not occur. If a downward movement would have caused a falling rock to move into the floor or an already-fallen rock, the falling rock stops where it is (having landed on something) and a new rock immediately begins falling.
     40 
     41 Drawing falling rocks with @ and stopped rocks with #, the jet pattern in the example above manifests as follows:
     42 
     43 The first rock begins falling:
     44 |..@@@@.|
     45 |.......|
     46 |.......|
     47 |.......|
     48 +-------+
     49 
     50 Jet of gas pushes rock right:
     51 |...@@@@|
     52 |.......|
     53 |.......|
     54 |.......|
     55 +-------+
     56 
     57 Rock falls 1 unit:
     58 |...@@@@|
     59 |.......|
     60 |.......|
     61 +-------+
     62 
     63 Jet of gas pushes rock right, but nothing happens:
     64 |...@@@@|
     65 |.......|
     66 |.......|
     67 +-------+
     68 
     69 Rock falls 1 unit:
     70 |...@@@@|
     71 |.......|
     72 +-------+
     73 
     74 Jet of gas pushes rock right, but nothing happens:
     75 |...@@@@|
     76 |.......|
     77 +-------+
     78 
     79 Rock falls 1 unit:
     80 |...@@@@|
     81 +-------+
     82 
     83 Jet of gas pushes rock left:
     84 |..@@@@.|
     85 +-------+
     86 
     87 Rock falls 1 unit, causing it to come to rest:
     88 |..####.|
     89 +-------+
     90 
     91 A new rock begins falling:
     92 |...@...|
     93 |..@@@..|
     94 |...@...|
     95 |.......|
     96 |.......|
     97 |.......|
     98 |..####.|
     99 +-------+
    100 
    101 Jet of gas pushes rock left:
    102 |..@....|
    103 |.@@@...|
    104 |..@....|
    105 |.......|
    106 |.......|
    107 |.......|
    108 |..####.|
    109 +-------+
    110 
    111 Rock falls 1 unit:
    112 |..@....|
    113 |.@@@...|
    114 |..@....|
    115 |.......|
    116 |.......|
    117 |..####.|
    118 +-------+
    119 
    120 Jet of gas pushes rock right:
    121 |...@...|
    122 |..@@@..|
    123 |...@...|
    124 |.......|
    125 |.......|
    126 |..####.|
    127 +-------+
    128 
    129 Rock falls 1 unit:
    130 |...@...|
    131 |..@@@..|
    132 |...@...|
    133 |.......|
    134 |..####.|
    135 +-------+
    136 
    137 Jet of gas pushes rock left:
    138 |..@....|
    139 |.@@@...|
    140 |..@....|
    141 |.......|
    142 |..####.|
    143 +-------+
    144 
    145 Rock falls 1 unit:
    146 |..@....|
    147 |.@@@...|
    148 |..@....|
    149 |..####.|
    150 +-------+
    151 
    152 Jet of gas pushes rock right:
    153 |...@...|
    154 |..@@@..|
    155 |...@...|
    156 |..####.|
    157 +-------+
    158 
    159 Rock falls 1 unit, causing it to come to rest:
    160 |...#...|
    161 |..###..|
    162 |...#...|
    163 |..####.|
    164 +-------+
    165 
    166 A new rock begins falling:
    167 |....@..|
    168 |....@..|
    169 |..@@@..|
    170 |.......|
    171 |.......|
    172 |.......|
    173 |...#...|
    174 |..###..|
    175 |...#...|
    176 |..####.|
    177 +-------+
    178 
    179 The moment each of the next few rocks begins falling, you would see this:
    180 
    181 |..@....|
    182 |..@....|
    183 |..@....|
    184 |..@....|
    185 |.......|
    186 |.......|
    187 |.......|
    188 |..#....|
    189 |..#....|
    190 |####...|
    191 |..###..|
    192 |...#...|
    193 |..####.|
    194 +-------+
    195 
    196 |..@@...|
    197 |..@@...|
    198 |.......|
    199 |.......|
    200 |.......|
    201 |....#..|
    202 |..#.#..|
    203 |..#.#..|
    204 |#####..|
    205 |..###..|
    206 |...#...|
    207 |..####.|
    208 +-------+
    209 
    210 |..@@@@.|
    211 |.......|
    212 |.......|
    213 |.......|
    214 |....##.|
    215 |....##.|
    216 |....#..|
    217 |..#.#..|
    218 |..#.#..|
    219 |#####..|
    220 |..###..|
    221 |...#...|
    222 |..####.|
    223 +-------+
    224 
    225 |...@...|
    226 |..@@@..|
    227 |...@...|
    228 |.......|
    229 |.......|
    230 |.......|
    231 |.####..|
    232 |....##.|
    233 |....##.|
    234 |....#..|
    235 |..#.#..|
    236 |..#.#..|
    237 |#####..|
    238 |..###..|
    239 |...#...|
    240 |..####.|
    241 +-------+
    242 
    243 |....@..|
    244 |....@..|
    245 |..@@@..|
    246 |.......|
    247 |.......|
    248 |.......|
    249 |..#....|
    250 |.###...|
    251 |..#....|
    252 |.####..|
    253 |....##.|
    254 |....##.|
    255 |....#..|
    256 |..#.#..|
    257 |..#.#..|
    258 |#####..|
    259 |..###..|
    260 |...#...|
    261 |..####.|
    262 +-------+
    263 
    264 |..@....|
    265 |..@....|
    266 |..@....|
    267 |..@....|
    268 |.......|
    269 |.......|
    270 |.......|
    271 |.....#.|
    272 |.....#.|
    273 |..####.|
    274 |.###...|
    275 |..#....|
    276 |.####..|
    277 |....##.|
    278 |....##.|
    279 |....#..|
    280 |..#.#..|
    281 |..#.#..|
    282 |#####..|
    283 |..###..|
    284 |...#...|
    285 |..####.|
    286 +-------+
    287 
    288 |..@@...|
    289 |..@@...|
    290 |.......|
    291 |.......|
    292 |.......|
    293 |....#..|
    294 |....#..|
    295 |....##.|
    296 |....##.|
    297 |..####.|
    298 |.###...|
    299 |..#....|
    300 |.####..|
    301 |....##.|
    302 |....##.|
    303 |....#..|
    304 |..#.#..|
    305 |..#.#..|
    306 |#####..|
    307 |..###..|
    308 |...#...|
    309 |..####.|
    310 +-------+
    311 
    312 |..@@@@.|
    313 |.......|
    314 |.......|
    315 |.......|
    316 |....#..|
    317 |....#..|
    318 |....##.|
    319 |##..##.|
    320 |######.|
    321 |.###...|
    322 |..#....|
    323 |.####..|
    324 |....##.|
    325 |....##.|
    326 |....#..|
    327 |..#.#..|
    328 |..#.#..|
    329 |#####..|
    330 |..###..|
    331 |...#...|
    332 |..####.|
    333 +-------+
    334 
    335 To prove to the elephants your simulation is accurate, they want to know how tall the tower will get after 2022 rocks have stopped (but before the 2023rd rock begins falling). In this example, the tower of rocks will be 3068 units tall.
    336 
    337 How many units tall will the tower of rocks be after 2022 rocks have stopped falling?
    338 
    339 Your puzzle answer was 3227.
    340 --- Part Two ---
    341 
    342 The elephants are not impressed by your simulation. They demand to know how tall the tower will be after 1000000000000 rocks have stopped! Only then will they feel confident enough to proceed through the cave.
    343 
    344 In the example above, the tower would be 1514285714288 units tall!
    345 
    346 How tall will the tower be after 1000000000000 rocks have stopped?
    347 
    348 Your puzzle answer was 1597714285698.