Bash: 2022 day 5 (both parts, brute code)
This commit is contained in:
@@ -88,4 +88,82 @@ Elves the message =CMZ=.
|
||||
/After the rearrangement procedure completes, what crate ends up on top
|
||||
of each stack?/
|
||||
|
||||
To begin, [[file:5/input][get your puzzle input]].
|
||||
Your puzzle answer was =VQZNJMWTR=.
|
||||
|
||||
** --- Part Two ---
|
||||
As you watch the crane operator expertly rearrange the crates, you
|
||||
notice the process isn't following your prediction.
|
||||
|
||||
Some mud was covering the writing on the side of the crane, and you
|
||||
quickly wipe it away. The crane isn't a CrateMover 9000 - it's a
|
||||
/CrateMover 9001/.
|
||||
|
||||
The CrateMover 9001 is notable for many new and exciting features: air
|
||||
conditioning, leather seats, an extra cup holder, and /the ability to
|
||||
pick up and move multiple crates at once/.
|
||||
|
||||
Again considering the example above, the crates begin in the same
|
||||
configuration:
|
||||
|
||||
#+begin_example
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
#+end_example
|
||||
|
||||
Moving a single crate from stack 2 to stack 1 behaves the same as
|
||||
before:
|
||||
|
||||
#+begin_example
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
#+end_example
|
||||
|
||||
However, the action of moving three crates from stack 1 to stack 3 means
|
||||
that those three moved crates /stay in the same order/, resulting in
|
||||
this new configuration:
|
||||
|
||||
#+begin_example
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
#+end_example
|
||||
|
||||
Next, as both crates are moved from stack 2 to stack 1, they /retain
|
||||
their order/ as well:
|
||||
|
||||
#+begin_example
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
#+end_example
|
||||
|
||||
Finally, a single crate is still moved from stack 1 to stack 2, but now
|
||||
it's crate =C= that gets moved:
|
||||
|
||||
#+begin_example
|
||||
[D]
|
||||
[N]
|
||||
[Z]
|
||||
[M] [C] [P]
|
||||
1 2 3
|
||||
#+end_example
|
||||
|
||||
In this example, the CrateMover 9001 has put the crates in a totally
|
||||
different order: =MCD=.
|
||||
|
||||
Before the rearrangement process finishes, update your simulation so
|
||||
that the Elves know where they should stand to be ready to unload the
|
||||
final supplies. /After the rearrangement procedure completes, what crate
|
||||
ends up on top of each stack?/
|
||||
|
||||
Your puzzle answer was =NLCDCLVMQ=.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
Reference in New Issue
Block a user