2022/day 5 init

This commit is contained in:
2022-12-08 12:45:04 +01:00
parent ab73311d6b
commit 64ad068ec8
8 changed files with 863 additions and 0 deletions

91
2022/day05/README.org Normal file
View File

@@ -0,0 +1,91 @@
** --- Day 5: Supply Stacks ---
The expedition can depart as soon as the final supplies have been
unloaded from the ships. Supplies are stored in stacks of marked
/crates/, but because the needed supplies are buried under many other
crates, the crates need to be rearranged.
The ship has a /giant cargo crane/ capable of moving crates between
stacks. To ensure none of the crates get crushed or fall over, the crane
operator will rearrange them in a series of carefully-planned steps.
After the crates are rearranged, the desired crates will be at the top
of each stack.
The Elves don't want to interrupt the crane operator during this
delicate procedure, but they forgot to ask her /which/ crate will end up
where, and they want to be ready to unload them as soon as possible so
they can embark.
They do, however, have a drawing of the starting stacks of crates /and/
the rearrangement procedure (your puzzle input). For example:
#+begin_example
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
#+end_example
In this example, there are three stacks of crates. Stack 1 contains two
crates: crate =Z= is on the bottom, and crate =N= is on top. Stack 2
contains three crates; from bottom to top, they are crates =M=, =C=, and
=D=. Finally, stack 3 contains a single crate, =P=.
Then, the rearrangement procedure is given. In each step of the
procedure, a quantity of crates is moved from one stack to a different
stack. In the first step of the above rearrangement procedure, one crate
is moved from stack 2 to stack 1, resulting in this configuration:
#+begin_example
[D]
[N] [C]
[Z] [M] [P]
1 2 3
#+end_example
In the second step, three crates are moved from stack 1 to stack 3.
Crates are moved /one at a time/, so the first crate to be moved (=D=)
ends up below the second and third crates:
#+begin_example
[Z]
[N]
[C] [D]
[M] [P]
1 2 3
#+end_example
Then, both crates are moved from stack 2 to stack 1. Again, because
crates are moved /one at a time/, crate =C= ends up below crate =M=:
#+begin_example
[Z]
[N]
[M] [D]
[C] [P]
1 2 3
#+end_example
Finally, one crate is moved from stack 1 to stack 2:
#+begin_example
[Z]
[N]
[D]
[C] [M] [P]
1 2 3
#+end_example
The Elves just need to know /which crate will end up on top of each
stack/; in this example, the top crates are =C= in stack 1, =M= in stack
2, and =Z= in stack 3, so you should combine these together and give the
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]].