diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-04-09 03:09:19 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-04-09 03:09:19 +0200 |
| commit | c827efeeef0cdc63c5366e9d945fa53c09988491 (patch) | |
| tree | e33361fa13742f5fd295e1e8525f388fca7fdda4 /2022/Cpp/Day5/puzzle.md | |
| parent | d5e8f8cb89c24e02898eed760ea22f0522e59f44 (diff) | |
| download | aoc-c827efeeef0cdc63c5366e9d945fa53c09988491.tar.xz aoc-c827efeeef0cdc63c5366e9d945fa53c09988491.zip | |
Solve day7 in rust
Diffstat (limited to '2022/Cpp/Day5/puzzle.md')
| -rwxr-xr-x | 2022/Cpp/Day5/puzzle.md | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/2022/Cpp/Day5/puzzle.md b/2022/Cpp/Day5/puzzle.md new file mode 100755 index 0000000..d56dfe0 --- /dev/null +++ b/2022/Cpp/Day5/puzzle.md @@ -0,0 +1,78 @@ +\--- 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: + +``` + [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 + +``` + +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: + +``` +[D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +``` + +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: + +``` + [Z] + [N] + [C] [D] + [M] [P] + 1 2 3 + +``` + +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`: + +``` + [Z] + [N] +[M] [D] +[C] [P] + 1 2 3 + +``` + +Finally, one crate is moved from stack 1 to stack 2: + +``` + [Z] + [N] + [D] +[C] [M] [P] + 1 2 3 + +``` + +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, [get your puzzle input](5/input). + +Answer: + +You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Supply+Stacks%22+%2D+Day+5+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
\ No newline at end of file |
