adventofcode/2022/day17/problem

440 lines
8.2 KiB
Plaintext
Raw Normal View History

2022-12-27 20:55:45 +00:00
Advent of Code
2022-12-20 21:04:26 +00:00
• [About]
• [Events]
• [Shop]
• [Settings]
• [Log Out]
2022-12-27 20:55:45 +00:00
br0xen (AoC++) 43*
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
  {year=>2022}
2022-12-20 21:04:26 +00:00
• [Calendar]
• [AoC++]
• [Sponsors]
• [Leaderboard]
• [Stats]
Our sponsors help make Advent of Code possible:
2022-12-27 20:55:45 +00:00
Teradyne - Do you like coding algorithms where milliseconds matter?
What about nanoseconds?
2022-12-20 21:04:26 +00:00
--- Day 17: Pyroclastic Flow ---
2022-12-27 20:55:45 +00:00
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.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
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!
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
The five types of rocks have the following peculiar shapes, where #
is rock and . is empty space:
2022-12-20 21:04:26 +00:00
####
.#.
###
.#.
..#
..#
###
#
#
#
#
##
##
2022-12-27 20:55:45 +00:00
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.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
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).
2022-12-20 21:04:26 +00:00
For example, suppose this was the jet pattern in your cave:
>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>
2022-12-27 20:55:45 +00:00
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.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
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).
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
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.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
Drawing falling rocks with @ and stopped rocks with #, the jet
pattern in the example above manifests as follows:
2022-12-20 21:04:26 +00:00
The first rock begins falling:
|..@@@@.|
|.......|
|.......|
|.......|
+-------+
Jet of gas pushes rock right:
|...@@@@|
|.......|
|.......|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
|.......|
|.......|
+-------+
Jet of gas pushes rock right, but nothing happens:
|...@@@@|
|.......|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
|.......|
+-------+
Jet of gas pushes rock right, but nothing happens:
|...@@@@|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
+-------+
Jet of gas pushes rock left:
|..@@@@.|
+-------+
Rock falls 1 unit, causing it to come to rest:
|..####.|
+-------+
A new rock begins falling:
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|.......|
|..####.|
+-------+
Jet of gas pushes rock left:
|..@....|
|.@@@...|
|..@....|
|.......|
|.......|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|..@....|
|.@@@...|
|..@....|
|.......|
|.......|
|..####.|
+-------+
Jet of gas pushes rock right:
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|...@...|
|..@@@..|
|...@...|
|.......|
|..####.|
+-------+
Jet of gas pushes rock left:
|..@....|
|.@@@...|
|..@....|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|..@....|
|.@@@...|
|..@....|
|..####.|
+-------+
Jet of gas pushes rock right:
|...@...|
|..@@@..|
|...@...|
|..####.|
+-------+
Rock falls 1 unit, causing it to come to rest:
|...#...|
|..###..|
|...#...|
|..####.|
+-------+
A new rock begins falling:
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|...#...|
|..###..|
|...#...|
|..####.|
+-------+
2022-12-27 20:55:45 +00:00
The moment each of the next few rocks begins falling, you would see
this:
2022-12-20 21:04:26 +00:00
|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|..#....|
|..#....|
|####...|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|.......|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|..#....|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|.....#.|
|.....#.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|....##.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|##..##.|
|######.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
2022-12-27 20:55:45 +00:00
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.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
How many units tall will the tower of rocks be after 2022 rocks have
stopped falling?
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
Your puzzle answer was 3081.
2022-12-20 21:04:26 +00:00
2022-12-27 20:55:45 +00:00
--- Part Two ---
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.
In the example above, the tower would be 1514285714288 units tall!
How tall will the tower be after 1000000000000 rocks have stopped?
Your puzzle answer was 1524637681145.
Both parts of this puzzle are complete! They provide two gold stars:
**
At this point, you should return to your Advent calendar and try
another puzzle.
If you still want to see it, you can get your puzzle input.
2022-12-20 21:04:26 +00:00
You can also [Shareon Twitter Mastodon] this puzzle.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2022/about
. https://adventofcode.com/2022/events
. https://teespring.com/stores/advent-of-code
. https://adventofcode.com/2022/settings
. https://adventofcode.com/2022/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2022/support
. https://adventofcode.com/2022
. https://adventofcode.com/2022
. https://adventofcode.com/2022/support
. https://adventofcode.com/2022/sponsors
. https://adventofcode.com/2022/leaderboard
. https://adventofcode.com/2022/stats
. https://adventofcode.com/2022/sponsors
2022-12-27 20:55:45 +00:00
. https://jobs.teradyne.com/?utm_source=adventofcode&utm_medium=ad&utm_campaign=2022
. https://adventofcode.com/2022
2022-12-20 21:04:26 +00:00
. https://adventofcode.com/2022/day/17/input
2022-12-27 20:55:45 +00:00
. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Pyroclastic+Flow%22+%2D+Day+17+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode
2022-12-20 21:04:26 +00:00
. javascript:void(0);