Solutions for 2022, as well as 2015-2018 and 2019 up to day 11
This commit is contained in:
commit
1895197c49
722 changed files with 375457 additions and 0 deletions
6
2022/day05-supply_stacks/Cargo.toml
Normal file
6
2022/day05-supply_stacks/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "day05-supply_stacks"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
96
2022/day05-supply_stacks/challenge.md
Normal file
96
2022/day05-supply_stacks/challenge.md
Normal file
|
@ -0,0 +1,96 @@
|
|||
--- 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?
|
||||
|
||||
--- 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:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
Moving a single crate from stack 2 to stack 1 behaves the same as before:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
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:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
Next, as both crates are moved from stack 2 to stack 1, they retain their order as well:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
Finally, a single crate is still moved from stack 1 to stack 2, but now it's crate C that gets moved:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[Z]
|
||||
[M] [C] [P]
|
||||
1 2 3
|
||||
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?
|
511
2022/day05-supply_stacks/input
Normal file
511
2022/day05-supply_stacks/input
Normal file
|
@ -0,0 +1,511 @@
|
|||
[V] [T] [J]
|
||||
[Q] [M] [P] [Q] [J]
|
||||
[W] [B] [N] [Q] [C] [T]
|
||||
[M] [C] [F] [N] [G] [W] [G]
|
||||
[B] [W] [J] [H] [L] [R] [B] [C]
|
||||
[N] [R] [R] [W] [W] [W] [D] [N] [F]
|
||||
[Z] [Z] [Q] [S] [F] [P] [B] [Q] [L]
|
||||
[C] [H] [F] [Z] [G] [L] [V] [Z] [H]
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
move 2 from 1 to 7
|
||||
move 6 from 2 to 6
|
||||
move 10 from 7 to 6
|
||||
move 4 from 3 to 1
|
||||
move 5 from 6 to 4
|
||||
move 1 from 1 to 9
|
||||
move 4 from 6 to 9
|
||||
move 12 from 4 to 1
|
||||
move 5 from 1 to 4
|
||||
move 7 from 9 to 8
|
||||
move 11 from 8 to 1
|
||||
move 6 from 6 to 2
|
||||
move 2 from 5 to 2
|
||||
move 3 from 6 to 3
|
||||
move 4 from 9 to 4
|
||||
move 2 from 2 to 5
|
||||
move 1 from 6 to 4
|
||||
move 3 from 3 to 6
|
||||
move 1 from 8 to 4
|
||||
move 1 from 6 to 1
|
||||
move 28 from 1 to 4
|
||||
move 28 from 4 to 5
|
||||
move 1 from 9 to 1
|
||||
move 4 from 4 to 1
|
||||
move 2 from 6 to 2
|
||||
move 2 from 1 to 6
|
||||
move 7 from 4 to 2
|
||||
move 14 from 2 to 9
|
||||
move 1 from 4 to 1
|
||||
move 1 from 1 to 2
|
||||
move 18 from 5 to 6
|
||||
move 2 from 2 to 6
|
||||
move 1 from 9 to 7
|
||||
move 8 from 9 to 2
|
||||
move 15 from 6 to 5
|
||||
move 1 from 6 to 3
|
||||
move 3 from 2 to 5
|
||||
move 1 from 7 to 5
|
||||
move 2 from 1 to 3
|
||||
move 3 from 2 to 1
|
||||
move 1 from 6 to 4
|
||||
move 5 from 6 to 5
|
||||
move 2 from 2 to 9
|
||||
move 35 from 5 to 7
|
||||
move 4 from 9 to 3
|
||||
move 1 from 4 to 1
|
||||
move 5 from 1 to 7
|
||||
move 6 from 5 to 3
|
||||
move 1 from 9 to 4
|
||||
move 11 from 7 to 6
|
||||
move 2 from 9 to 2
|
||||
move 1 from 4 to 7
|
||||
move 14 from 7 to 4
|
||||
move 5 from 6 to 9
|
||||
move 2 from 2 to 4
|
||||
move 6 from 7 to 9
|
||||
move 2 from 9 to 5
|
||||
move 6 from 9 to 5
|
||||
move 8 from 4 to 9
|
||||
move 5 from 4 to 3
|
||||
move 3 from 5 to 7
|
||||
move 1 from 3 to 9
|
||||
move 5 from 3 to 4
|
||||
move 7 from 9 to 8
|
||||
move 2 from 7 to 4
|
||||
move 4 from 5 to 7
|
||||
move 1 from 5 to 3
|
||||
move 5 from 6 to 4
|
||||
move 8 from 4 to 8
|
||||
move 5 from 7 to 6
|
||||
move 1 from 4 to 7
|
||||
move 3 from 6 to 9
|
||||
move 2 from 6 to 5
|
||||
move 7 from 8 to 3
|
||||
move 2 from 5 to 9
|
||||
move 17 from 3 to 1
|
||||
move 3 from 1 to 3
|
||||
move 6 from 8 to 9
|
||||
move 4 from 4 to 7
|
||||
move 6 from 3 to 5
|
||||
move 2 from 8 to 5
|
||||
move 14 from 7 to 5
|
||||
move 2 from 4 to 5
|
||||
move 6 from 9 to 5
|
||||
move 1 from 7 to 9
|
||||
move 1 from 6 to 9
|
||||
move 8 from 1 to 9
|
||||
move 8 from 5 to 2
|
||||
move 2 from 1 to 3
|
||||
move 7 from 2 to 6
|
||||
move 2 from 3 to 4
|
||||
move 1 from 2 to 6
|
||||
move 3 from 1 to 6
|
||||
move 16 from 9 to 4
|
||||
move 2 from 9 to 8
|
||||
move 1 from 1 to 6
|
||||
move 2 from 9 to 4
|
||||
move 1 from 6 to 9
|
||||
move 1 from 6 to 1
|
||||
move 1 from 1 to 7
|
||||
move 1 from 6 to 9
|
||||
move 1 from 9 to 3
|
||||
move 1 from 3 to 8
|
||||
move 1 from 9 to 2
|
||||
move 1 from 2 to 7
|
||||
move 2 from 5 to 3
|
||||
move 7 from 5 to 8
|
||||
move 2 from 7 to 9
|
||||
move 1 from 6 to 7
|
||||
move 3 from 6 to 9
|
||||
move 10 from 8 to 7
|
||||
move 1 from 4 to 3
|
||||
move 3 from 3 to 1
|
||||
move 1 from 7 to 1
|
||||
move 19 from 4 to 6
|
||||
move 3 from 9 to 7
|
||||
move 1 from 9 to 2
|
||||
move 2 from 1 to 7
|
||||
move 1 from 9 to 1
|
||||
move 12 from 6 to 9
|
||||
move 2 from 7 to 1
|
||||
move 1 from 2 to 4
|
||||
move 11 from 6 to 3
|
||||
move 1 from 4 to 8
|
||||
move 1 from 6 to 8
|
||||
move 11 from 7 to 9
|
||||
move 2 from 8 to 9
|
||||
move 18 from 9 to 6
|
||||
move 5 from 3 to 7
|
||||
move 5 from 3 to 8
|
||||
move 11 from 5 to 6
|
||||
move 26 from 6 to 4
|
||||
move 1 from 6 to 5
|
||||
move 1 from 3 to 7
|
||||
move 3 from 8 to 3
|
||||
move 1 from 8 to 7
|
||||
move 3 from 3 to 6
|
||||
move 5 from 9 to 3
|
||||
move 1 from 4 to 9
|
||||
move 8 from 4 to 5
|
||||
move 2 from 7 to 8
|
||||
move 3 from 3 to 6
|
||||
move 3 from 4 to 6
|
||||
move 7 from 7 to 4
|
||||
move 1 from 9 to 1
|
||||
move 5 from 5 to 3
|
||||
move 2 from 9 to 7
|
||||
move 3 from 8 to 2
|
||||
move 7 from 3 to 7
|
||||
move 1 from 7 to 6
|
||||
move 3 from 5 to 6
|
||||
move 7 from 4 to 8
|
||||
move 10 from 4 to 5
|
||||
move 2 from 4 to 2
|
||||
move 3 from 7 to 5
|
||||
move 2 from 4 to 1
|
||||
move 6 from 8 to 5
|
||||
move 5 from 1 to 4
|
||||
move 5 from 4 to 2
|
||||
move 5 from 7 to 8
|
||||
move 10 from 2 to 8
|
||||
move 3 from 8 to 3
|
||||
move 2 from 5 to 3
|
||||
move 13 from 6 to 1
|
||||
move 19 from 5 to 3
|
||||
move 12 from 3 to 9
|
||||
move 4 from 8 to 2
|
||||
move 2 from 6 to 7
|
||||
move 5 from 8 to 7
|
||||
move 9 from 3 to 9
|
||||
move 1 from 5 to 9
|
||||
move 2 from 7 to 6
|
||||
move 3 from 2 to 3
|
||||
move 15 from 9 to 3
|
||||
move 13 from 3 to 5
|
||||
move 1 from 6 to 2
|
||||
move 5 from 5 to 8
|
||||
move 1 from 2 to 5
|
||||
move 1 from 7 to 6
|
||||
move 6 from 9 to 6
|
||||
move 6 from 6 to 8
|
||||
move 4 from 7 to 1
|
||||
move 2 from 3 to 6
|
||||
move 11 from 1 to 9
|
||||
move 1 from 2 to 3
|
||||
move 4 from 5 to 6
|
||||
move 1 from 1 to 6
|
||||
move 10 from 9 to 2
|
||||
move 8 from 2 to 3
|
||||
move 3 from 1 to 2
|
||||
move 8 from 3 to 1
|
||||
move 5 from 5 to 4
|
||||
move 1 from 9 to 8
|
||||
move 2 from 3 to 7
|
||||
move 2 from 4 to 5
|
||||
move 6 from 1 to 6
|
||||
move 9 from 8 to 1
|
||||
move 16 from 1 to 9
|
||||
move 2 from 7 to 3
|
||||
move 3 from 3 to 8
|
||||
move 6 from 9 to 6
|
||||
move 1 from 5 to 4
|
||||
move 1 from 3 to 8
|
||||
move 5 from 2 to 1
|
||||
move 5 from 1 to 9
|
||||
move 2 from 4 to 9
|
||||
move 4 from 8 to 6
|
||||
move 1 from 8 to 7
|
||||
move 4 from 8 to 5
|
||||
move 2 from 8 to 2
|
||||
move 17 from 9 to 5
|
||||
move 11 from 5 to 7
|
||||
move 1 from 2 to 5
|
||||
move 1 from 2 to 5
|
||||
move 1 from 9 to 1
|
||||
move 1 from 1 to 6
|
||||
move 5 from 7 to 6
|
||||
move 20 from 6 to 7
|
||||
move 4 from 6 to 4
|
||||
move 15 from 7 to 8
|
||||
move 2 from 3 to 7
|
||||
move 1 from 6 to 5
|
||||
move 10 from 8 to 4
|
||||
move 1 from 3 to 6
|
||||
move 4 from 6 to 4
|
||||
move 13 from 7 to 8
|
||||
move 1 from 7 to 5
|
||||
move 1 from 6 to 3
|
||||
move 1 from 6 to 3
|
||||
move 1 from 6 to 9
|
||||
move 9 from 4 to 1
|
||||
move 3 from 8 to 2
|
||||
move 14 from 5 to 6
|
||||
move 2 from 2 to 8
|
||||
move 1 from 3 to 9
|
||||
move 14 from 6 to 2
|
||||
move 1 from 3 to 9
|
||||
move 1 from 9 to 3
|
||||
move 15 from 2 to 1
|
||||
move 1 from 3 to 9
|
||||
move 4 from 4 to 9
|
||||
move 10 from 8 to 5
|
||||
move 1 from 9 to 5
|
||||
move 1 from 1 to 5
|
||||
move 4 from 8 to 7
|
||||
move 3 from 9 to 3
|
||||
move 1 from 8 to 5
|
||||
move 1 from 4 to 7
|
||||
move 2 from 8 to 7
|
||||
move 6 from 5 to 6
|
||||
move 4 from 1 to 2
|
||||
move 1 from 2 to 5
|
||||
move 2 from 2 to 8
|
||||
move 2 from 8 to 1
|
||||
move 3 from 7 to 2
|
||||
move 3 from 4 to 9
|
||||
move 18 from 1 to 8
|
||||
move 1 from 7 to 3
|
||||
move 3 from 9 to 6
|
||||
move 1 from 1 to 5
|
||||
move 5 from 6 to 4
|
||||
move 2 from 1 to 9
|
||||
move 8 from 4 to 5
|
||||
move 4 from 3 to 2
|
||||
move 16 from 5 to 4
|
||||
move 8 from 8 to 6
|
||||
move 2 from 2 to 6
|
||||
move 1 from 7 to 6
|
||||
move 7 from 8 to 1
|
||||
move 1 from 2 to 3
|
||||
move 2 from 8 to 3
|
||||
move 4 from 4 to 9
|
||||
move 4 from 1 to 2
|
||||
move 1 from 7 to 2
|
||||
move 1 from 5 to 4
|
||||
move 1 from 3 to 7
|
||||
move 3 from 4 to 5
|
||||
move 1 from 9 to 6
|
||||
move 9 from 2 to 5
|
||||
move 2 from 3 to 6
|
||||
move 3 from 5 to 8
|
||||
move 3 from 1 to 7
|
||||
move 4 from 5 to 8
|
||||
move 1 from 4 to 3
|
||||
move 5 from 9 to 5
|
||||
move 5 from 5 to 8
|
||||
move 1 from 3 to 4
|
||||
move 4 from 5 to 1
|
||||
move 2 from 5 to 4
|
||||
move 13 from 6 to 2
|
||||
move 12 from 2 to 9
|
||||
move 3 from 9 to 2
|
||||
move 4 from 1 to 6
|
||||
move 8 from 6 to 2
|
||||
move 1 from 4 to 9
|
||||
move 3 from 7 to 9
|
||||
move 2 from 9 to 8
|
||||
move 1 from 7 to 2
|
||||
move 9 from 9 to 5
|
||||
move 2 from 8 to 6
|
||||
move 4 from 2 to 3
|
||||
move 1 from 7 to 2
|
||||
move 1 from 6 to 4
|
||||
move 4 from 3 to 9
|
||||
move 9 from 5 to 8
|
||||
move 10 from 4 to 2
|
||||
move 1 from 4 to 7
|
||||
move 1 from 6 to 2
|
||||
move 1 from 6 to 7
|
||||
move 13 from 2 to 6
|
||||
move 1 from 2 to 5
|
||||
move 6 from 6 to 5
|
||||
move 7 from 5 to 8
|
||||
move 1 from 4 to 5
|
||||
move 27 from 8 to 5
|
||||
move 3 from 6 to 3
|
||||
move 2 from 8 to 6
|
||||
move 8 from 9 to 5
|
||||
move 1 from 7 to 9
|
||||
move 1 from 6 to 2
|
||||
move 4 from 5 to 9
|
||||
move 2 from 3 to 4
|
||||
move 9 from 2 to 5
|
||||
move 1 from 4 to 1
|
||||
move 1 from 4 to 2
|
||||
move 1 from 2 to 4
|
||||
move 1 from 3 to 7
|
||||
move 1 from 1 to 3
|
||||
move 1 from 3 to 9
|
||||
move 6 from 9 to 4
|
||||
move 1 from 7 to 5
|
||||
move 13 from 5 to 2
|
||||
move 1 from 9 to 5
|
||||
move 1 from 7 to 2
|
||||
move 5 from 2 to 7
|
||||
move 8 from 5 to 7
|
||||
move 6 from 4 to 2
|
||||
move 1 from 4 to 5
|
||||
move 3 from 2 to 4
|
||||
move 4 from 2 to 7
|
||||
move 2 from 4 to 3
|
||||
move 13 from 7 to 3
|
||||
move 5 from 2 to 3
|
||||
move 4 from 7 to 8
|
||||
move 11 from 3 to 8
|
||||
move 11 from 5 to 9
|
||||
move 4 from 6 to 9
|
||||
move 1 from 6 to 5
|
||||
move 1 from 4 to 2
|
||||
move 1 from 3 to 6
|
||||
move 3 from 2 to 6
|
||||
move 3 from 6 to 2
|
||||
move 1 from 6 to 1
|
||||
move 1 from 3 to 8
|
||||
move 3 from 3 to 6
|
||||
move 2 from 2 to 7
|
||||
move 4 from 3 to 9
|
||||
move 16 from 9 to 2
|
||||
move 1 from 7 to 8
|
||||
move 2 from 2 to 8
|
||||
move 9 from 2 to 3
|
||||
move 6 from 2 to 7
|
||||
move 1 from 6 to 3
|
||||
move 2 from 9 to 2
|
||||
move 1 from 9 to 7
|
||||
move 2 from 6 to 3
|
||||
move 4 from 3 to 9
|
||||
move 2 from 2 to 7
|
||||
move 1 from 2 to 5
|
||||
move 14 from 5 to 6
|
||||
move 14 from 6 to 3
|
||||
move 4 from 9 to 8
|
||||
move 5 from 8 to 4
|
||||
move 1 from 1 to 5
|
||||
move 4 from 8 to 1
|
||||
move 1 from 5 to 9
|
||||
move 8 from 7 to 2
|
||||
move 18 from 3 to 7
|
||||
move 1 from 1 to 5
|
||||
move 1 from 1 to 9
|
||||
move 1 from 4 to 5
|
||||
move 1 from 8 to 5
|
||||
move 8 from 2 to 9
|
||||
move 3 from 5 to 8
|
||||
move 7 from 7 to 1
|
||||
move 3 from 4 to 7
|
||||
move 1 from 3 to 6
|
||||
move 7 from 8 to 3
|
||||
move 2 from 9 to 3
|
||||
move 3 from 8 to 9
|
||||
move 9 from 1 to 7
|
||||
move 9 from 3 to 4
|
||||
move 2 from 3 to 4
|
||||
move 12 from 7 to 4
|
||||
move 1 from 3 to 8
|
||||
move 1 from 8 to 7
|
||||
move 8 from 4 to 7
|
||||
move 11 from 4 to 9
|
||||
move 5 from 4 to 8
|
||||
move 19 from 7 to 9
|
||||
move 1 from 6 to 2
|
||||
move 2 from 7 to 4
|
||||
move 2 from 8 to 3
|
||||
move 1 from 7 to 8
|
||||
move 1 from 3 to 2
|
||||
move 3 from 8 to 4
|
||||
move 1 from 8 to 9
|
||||
move 1 from 3 to 2
|
||||
move 36 from 9 to 1
|
||||
move 5 from 9 to 6
|
||||
move 5 from 4 to 2
|
||||
move 24 from 1 to 3
|
||||
move 5 from 6 to 7
|
||||
move 1 from 1 to 4
|
||||
move 14 from 3 to 4
|
||||
move 4 from 7 to 3
|
||||
move 1 from 8 to 5
|
||||
move 5 from 2 to 9
|
||||
move 1 from 1 to 6
|
||||
move 5 from 9 to 1
|
||||
move 3 from 2 to 3
|
||||
move 1 from 5 to 3
|
||||
move 11 from 4 to 2
|
||||
move 1 from 7 to 1
|
||||
move 6 from 1 to 9
|
||||
move 3 from 4 to 2
|
||||
move 1 from 6 to 7
|
||||
move 10 from 1 to 7
|
||||
move 3 from 2 to 1
|
||||
move 3 from 3 to 2
|
||||
move 2 from 1 to 7
|
||||
move 1 from 4 to 8
|
||||
move 13 from 3 to 2
|
||||
move 1 from 8 to 3
|
||||
move 2 from 7 to 5
|
||||
move 2 from 3 to 7
|
||||
move 2 from 5 to 2
|
||||
move 1 from 1 to 7
|
||||
move 28 from 2 to 6
|
||||
move 1 from 2 to 3
|
||||
move 2 from 8 to 2
|
||||
move 6 from 9 to 7
|
||||
move 1 from 3 to 8
|
||||
move 1 from 9 to 8
|
||||
move 3 from 6 to 2
|
||||
move 14 from 7 to 9
|
||||
move 3 from 2 to 1
|
||||
move 2 from 2 to 9
|
||||
move 2 from 1 to 9
|
||||
move 1 from 9 to 1
|
||||
move 7 from 6 to 9
|
||||
move 2 from 1 to 4
|
||||
move 2 from 4 to 6
|
||||
move 4 from 8 to 7
|
||||
move 1 from 7 to 6
|
||||
move 1 from 8 to 1
|
||||
move 1 from 3 to 6
|
||||
move 1 from 1 to 5
|
||||
move 14 from 9 to 8
|
||||
move 1 from 5 to 9
|
||||
move 5 from 7 to 3
|
||||
move 16 from 6 to 3
|
||||
move 2 from 7 to 4
|
||||
move 8 from 9 to 5
|
||||
move 6 from 6 to 1
|
||||
move 8 from 5 to 9
|
||||
move 2 from 7 to 4
|
||||
move 11 from 9 to 1
|
||||
move 4 from 4 to 1
|
||||
move 14 from 8 to 3
|
||||
move 2 from 1 to 7
|
||||
move 20 from 3 to 6
|
||||
move 5 from 3 to 1
|
||||
move 1 from 3 to 5
|
||||
move 2 from 7 to 4
|
||||
move 20 from 6 to 7
|
||||
move 18 from 7 to 6
|
||||
move 17 from 6 to 9
|
||||
move 1 from 5 to 3
|
||||
move 6 from 3 to 2
|
||||
move 3 from 3 to 1
|
||||
move 1 from 6 to 2
|
||||
move 2 from 7 to 8
|
||||
move 4 from 1 to 5
|
||||
move 2 from 4 to 9
|
||||
move 1 from 3 to 2
|
||||
move 1 from 8 to 6
|
||||
move 18 from 1 to 4
|
||||
move 1 from 2 to 7
|
||||
move 1 from 6 to 2
|
||||
move 3 from 4 to 3
|
||||
move 1 from 8 to 1
|
||||
move 4 from 1 to 6
|
||||
move 7 from 2 to 1
|
||||
move 1 from 5 to 7
|
||||
move 1 from 4 to 1
|
||||
move 2 from 6 to 3
|
||||
move 3 from 5 to 9
|
||||
move 9 from 9 to 8
|
||||
move 10 from 9 to 3
|
||||
move 9 from 3 to 5
|
109
2022/day05-supply_stacks/src/main.rs
Normal file
109
2022/day05-supply_stacks/src/main.rs
Normal file
|
@ -0,0 +1,109 @@
|
|||
use std::fs;
|
||||
|
||||
enum Mode { SingleCrate, MultiCrate }
|
||||
|
||||
#[derive(Clone)]
|
||||
struct State {
|
||||
stacks: Vec<Vec<char>>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
fn from_initial(initial_state: &str) -> Self {
|
||||
let stack_count = (initial_state.lines().last().unwrap().len() + 1) / 4;
|
||||
let mut stacks = vec![Vec::new(); stack_count];
|
||||
|
||||
for line in initial_state.lines().rev().skip(1) {
|
||||
for stack in 0..stack_count {
|
||||
let supply_crate = line.chars().nth(stack*4+1).unwrap();
|
||||
if supply_crate != ' ' {
|
||||
stacks[stack].push(supply_crate);
|
||||
}
|
||||
}
|
||||
}
|
||||
State {
|
||||
stacks,
|
||||
}
|
||||
}
|
||||
|
||||
fn move_crates(&mut self, crate_count: usize, source: usize, destination: usize,) {
|
||||
let source_length = self.stacks[source].len();
|
||||
let mut move_stack = self.stacks[source].split_off(source_length-crate_count);
|
||||
self.stacks[destination].append(&mut move_stack);
|
||||
}
|
||||
|
||||
fn perform(&mut self, instruction: &str, operation_mode: Mode) {
|
||||
let elements: Vec<&str> = instruction.split(' ').collect();
|
||||
if elements.len()>4 {
|
||||
let (crate_count, source, destination) = (elements[1].parse::<usize>().unwrap(), elements[3].parse::<usize>().unwrap(), elements[5].parse::<usize>().unwrap());
|
||||
match operation_mode {
|
||||
Mode::SingleCrate => for _ in 0..crate_count {
|
||||
self.move_crates(1, source-1, destination-1);
|
||||
},
|
||||
Mode::MultiCrate => {self.move_crates(crate_count, source-1, destination-1);},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn top_str(&self) -> String {
|
||||
self.stacks.iter()
|
||||
.map(|stack| stack.last().unwrap_or(&' '))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn read_file(path: &str) -> String {
|
||||
fs::read_to_string(path)
|
||||
.expect("File not Found")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
//let contents = read_file("sample_input");
|
||||
let contents = read_file("input");
|
||||
|
||||
if let Some((initial_state, instructions)) = contents.split_once("\n\n") {
|
||||
let mut state_9000 = State::from_initial(initial_state);
|
||||
let mut state_9001 = state_9000.clone();
|
||||
for instruction in instructions.lines() {
|
||||
state_9000.perform(instruction, Mode::SingleCrate);
|
||||
state_9001.perform(instruction, Mode::MultiCrate);
|
||||
}
|
||||
println!("With CrateMover 9000, the top crates at the end are {}", state_9000.top_str());
|
||||
println!("With CrateMover 9001, the top crates at the end are {}", state_9001.top_str());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sample_input() {
|
||||
let contents = read_file("tests/sample_input");
|
||||
|
||||
if let Some((initial_state, instructions)) = contents.split_once("\n\n") {
|
||||
let mut state_9000 = State::from_initial(initial_state);
|
||||
let mut state_9001 = state_9000.clone();
|
||||
for instruction in instructions.lines() {
|
||||
state_9000.perform(instruction, Mode::SingleCrate);
|
||||
state_9001.perform(instruction, Mode::MultiCrate);
|
||||
}
|
||||
assert_eq!(state_9000.top_str(), "CMZ");
|
||||
assert_eq!(state_9001.top_str(), "MCD");
|
||||
} else {
|
||||
panic!("Unable to split input: {contents}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn challenge_input() {
|
||||
let contents = read_file("tests/input");
|
||||
|
||||
if let Some((initial_state, instructions)) = contents.split_once("\n\n") {
|
||||
let mut state_9000 = State::from_initial(initial_state);
|
||||
let mut state_9001 = state_9000.clone();
|
||||
for instruction in instructions.lines() {
|
||||
state_9000.perform(instruction, Mode::SingleCrate);
|
||||
state_9001.perform(instruction, Mode::MultiCrate);
|
||||
}
|
||||
assert_eq!(state_9000.top_str(), "QNHWJVJZW");
|
||||
assert_eq!(state_9001.top_str(), "BPCZJLFJW");
|
||||
} else {
|
||||
panic!("Unable to split input: {contents}");
|
||||
}
|
||||
}
|
511
2022/day05-supply_stacks/tests/input
Normal file
511
2022/day05-supply_stacks/tests/input
Normal file
|
@ -0,0 +1,511 @@
|
|||
[V] [T] [J]
|
||||
[Q] [M] [P] [Q] [J]
|
||||
[W] [B] [N] [Q] [C] [T]
|
||||
[M] [C] [F] [N] [G] [W] [G]
|
||||
[B] [W] [J] [H] [L] [R] [B] [C]
|
||||
[N] [R] [R] [W] [W] [W] [D] [N] [F]
|
||||
[Z] [Z] [Q] [S] [F] [P] [B] [Q] [L]
|
||||
[C] [H] [F] [Z] [G] [L] [V] [Z] [H]
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
move 2 from 1 to 7
|
||||
move 6 from 2 to 6
|
||||
move 10 from 7 to 6
|
||||
move 4 from 3 to 1
|
||||
move 5 from 6 to 4
|
||||
move 1 from 1 to 9
|
||||
move 4 from 6 to 9
|
||||
move 12 from 4 to 1
|
||||
move 5 from 1 to 4
|
||||
move 7 from 9 to 8
|
||||
move 11 from 8 to 1
|
||||
move 6 from 6 to 2
|
||||
move 2 from 5 to 2
|
||||
move 3 from 6 to 3
|
||||
move 4 from 9 to 4
|
||||
move 2 from 2 to 5
|
||||
move 1 from 6 to 4
|
||||
move 3 from 3 to 6
|
||||
move 1 from 8 to 4
|
||||
move 1 from 6 to 1
|
||||
move 28 from 1 to 4
|
||||
move 28 from 4 to 5
|
||||
move 1 from 9 to 1
|
||||
move 4 from 4 to 1
|
||||
move 2 from 6 to 2
|
||||
move 2 from 1 to 6
|
||||
move 7 from 4 to 2
|
||||
move 14 from 2 to 9
|
||||
move 1 from 4 to 1
|
||||
move 1 from 1 to 2
|
||||
move 18 from 5 to 6
|
||||
move 2 from 2 to 6
|
||||
move 1 from 9 to 7
|
||||
move 8 from 9 to 2
|
||||
move 15 from 6 to 5
|
||||
move 1 from 6 to 3
|
||||
move 3 from 2 to 5
|
||||
move 1 from 7 to 5
|
||||
move 2 from 1 to 3
|
||||
move 3 from 2 to 1
|
||||
move 1 from 6 to 4
|
||||
move 5 from 6 to 5
|
||||
move 2 from 2 to 9
|
||||
move 35 from 5 to 7
|
||||
move 4 from 9 to 3
|
||||
move 1 from 4 to 1
|
||||
move 5 from 1 to 7
|
||||
move 6 from 5 to 3
|
||||
move 1 from 9 to 4
|
||||
move 11 from 7 to 6
|
||||
move 2 from 9 to 2
|
||||
move 1 from 4 to 7
|
||||
move 14 from 7 to 4
|
||||
move 5 from 6 to 9
|
||||
move 2 from 2 to 4
|
||||
move 6 from 7 to 9
|
||||
move 2 from 9 to 5
|
||||
move 6 from 9 to 5
|
||||
move 8 from 4 to 9
|
||||
move 5 from 4 to 3
|
||||
move 3 from 5 to 7
|
||||
move 1 from 3 to 9
|
||||
move 5 from 3 to 4
|
||||
move 7 from 9 to 8
|
||||
move 2 from 7 to 4
|
||||
move 4 from 5 to 7
|
||||
move 1 from 5 to 3
|
||||
move 5 from 6 to 4
|
||||
move 8 from 4 to 8
|
||||
move 5 from 7 to 6
|
||||
move 1 from 4 to 7
|
||||
move 3 from 6 to 9
|
||||
move 2 from 6 to 5
|
||||
move 7 from 8 to 3
|
||||
move 2 from 5 to 9
|
||||
move 17 from 3 to 1
|
||||
move 3 from 1 to 3
|
||||
move 6 from 8 to 9
|
||||
move 4 from 4 to 7
|
||||
move 6 from 3 to 5
|
||||
move 2 from 8 to 5
|
||||
move 14 from 7 to 5
|
||||
move 2 from 4 to 5
|
||||
move 6 from 9 to 5
|
||||
move 1 from 7 to 9
|
||||
move 1 from 6 to 9
|
||||
move 8 from 1 to 9
|
||||
move 8 from 5 to 2
|
||||
move 2 from 1 to 3
|
||||
move 7 from 2 to 6
|
||||
move 2 from 3 to 4
|
||||
move 1 from 2 to 6
|
||||
move 3 from 1 to 6
|
||||
move 16 from 9 to 4
|
||||
move 2 from 9 to 8
|
||||
move 1 from 1 to 6
|
||||
move 2 from 9 to 4
|
||||
move 1 from 6 to 9
|
||||
move 1 from 6 to 1
|
||||
move 1 from 1 to 7
|
||||
move 1 from 6 to 9
|
||||
move 1 from 9 to 3
|
||||
move 1 from 3 to 8
|
||||
move 1 from 9 to 2
|
||||
move 1 from 2 to 7
|
||||
move 2 from 5 to 3
|
||||
move 7 from 5 to 8
|
||||
move 2 from 7 to 9
|
||||
move 1 from 6 to 7
|
||||
move 3 from 6 to 9
|
||||
move 10 from 8 to 7
|
||||
move 1 from 4 to 3
|
||||
move 3 from 3 to 1
|
||||
move 1 from 7 to 1
|
||||
move 19 from 4 to 6
|
||||
move 3 from 9 to 7
|
||||
move 1 from 9 to 2
|
||||
move 2 from 1 to 7
|
||||
move 1 from 9 to 1
|
||||
move 12 from 6 to 9
|
||||
move 2 from 7 to 1
|
||||
move 1 from 2 to 4
|
||||
move 11 from 6 to 3
|
||||
move 1 from 4 to 8
|
||||
move 1 from 6 to 8
|
||||
move 11 from 7 to 9
|
||||
move 2 from 8 to 9
|
||||
move 18 from 9 to 6
|
||||
move 5 from 3 to 7
|
||||
move 5 from 3 to 8
|
||||
move 11 from 5 to 6
|
||||
move 26 from 6 to 4
|
||||
move 1 from 6 to 5
|
||||
move 1 from 3 to 7
|
||||
move 3 from 8 to 3
|
||||
move 1 from 8 to 7
|
||||
move 3 from 3 to 6
|
||||
move 5 from 9 to 3
|
||||
move 1 from 4 to 9
|
||||
move 8 from 4 to 5
|
||||
move 2 from 7 to 8
|
||||
move 3 from 3 to 6
|
||||
move 3 from 4 to 6
|
||||
move 7 from 7 to 4
|
||||
move 1 from 9 to 1
|
||||
move 5 from 5 to 3
|
||||
move 2 from 9 to 7
|
||||
move 3 from 8 to 2
|
||||
move 7 from 3 to 7
|
||||
move 1 from 7 to 6
|
||||
move 3 from 5 to 6
|
||||
move 7 from 4 to 8
|
||||
move 10 from 4 to 5
|
||||
move 2 from 4 to 2
|
||||
move 3 from 7 to 5
|
||||
move 2 from 4 to 1
|
||||
move 6 from 8 to 5
|
||||
move 5 from 1 to 4
|
||||
move 5 from 4 to 2
|
||||
move 5 from 7 to 8
|
||||
move 10 from 2 to 8
|
||||
move 3 from 8 to 3
|
||||
move 2 from 5 to 3
|
||||
move 13 from 6 to 1
|
||||
move 19 from 5 to 3
|
||||
move 12 from 3 to 9
|
||||
move 4 from 8 to 2
|
||||
move 2 from 6 to 7
|
||||
move 5 from 8 to 7
|
||||
move 9 from 3 to 9
|
||||
move 1 from 5 to 9
|
||||
move 2 from 7 to 6
|
||||
move 3 from 2 to 3
|
||||
move 15 from 9 to 3
|
||||
move 13 from 3 to 5
|
||||
move 1 from 6 to 2
|
||||
move 5 from 5 to 8
|
||||
move 1 from 2 to 5
|
||||
move 1 from 7 to 6
|
||||
move 6 from 9 to 6
|
||||
move 6 from 6 to 8
|
||||
move 4 from 7 to 1
|
||||
move 2 from 3 to 6
|
||||
move 11 from 1 to 9
|
||||
move 1 from 2 to 3
|
||||
move 4 from 5 to 6
|
||||
move 1 from 1 to 6
|
||||
move 10 from 9 to 2
|
||||
move 8 from 2 to 3
|
||||
move 3 from 1 to 2
|
||||
move 8 from 3 to 1
|
||||
move 5 from 5 to 4
|
||||
move 1 from 9 to 8
|
||||
move 2 from 3 to 7
|
||||
move 2 from 4 to 5
|
||||
move 6 from 1 to 6
|
||||
move 9 from 8 to 1
|
||||
move 16 from 1 to 9
|
||||
move 2 from 7 to 3
|
||||
move 3 from 3 to 8
|
||||
move 6 from 9 to 6
|
||||
move 1 from 5 to 4
|
||||
move 1 from 3 to 8
|
||||
move 5 from 2 to 1
|
||||
move 5 from 1 to 9
|
||||
move 2 from 4 to 9
|
||||
move 4 from 8 to 6
|
||||
move 1 from 8 to 7
|
||||
move 4 from 8 to 5
|
||||
move 2 from 8 to 2
|
||||
move 17 from 9 to 5
|
||||
move 11 from 5 to 7
|
||||
move 1 from 2 to 5
|
||||
move 1 from 2 to 5
|
||||
move 1 from 9 to 1
|
||||
move 1 from 1 to 6
|
||||
move 5 from 7 to 6
|
||||
move 20 from 6 to 7
|
||||
move 4 from 6 to 4
|
||||
move 15 from 7 to 8
|
||||
move 2 from 3 to 7
|
||||
move 1 from 6 to 5
|
||||
move 10 from 8 to 4
|
||||
move 1 from 3 to 6
|
||||
move 4 from 6 to 4
|
||||
move 13 from 7 to 8
|
||||
move 1 from 7 to 5
|
||||
move 1 from 6 to 3
|
||||
move 1 from 6 to 3
|
||||
move 1 from 6 to 9
|
||||
move 9 from 4 to 1
|
||||
move 3 from 8 to 2
|
||||
move 14 from 5 to 6
|
||||
move 2 from 2 to 8
|
||||
move 1 from 3 to 9
|
||||
move 14 from 6 to 2
|
||||
move 1 from 3 to 9
|
||||
move 1 from 9 to 3
|
||||
move 15 from 2 to 1
|
||||
move 1 from 3 to 9
|
||||
move 4 from 4 to 9
|
||||
move 10 from 8 to 5
|
||||
move 1 from 9 to 5
|
||||
move 1 from 1 to 5
|
||||
move 4 from 8 to 7
|
||||
move 3 from 9 to 3
|
||||
move 1 from 8 to 5
|
||||
move 1 from 4 to 7
|
||||
move 2 from 8 to 7
|
||||
move 6 from 5 to 6
|
||||
move 4 from 1 to 2
|
||||
move 1 from 2 to 5
|
||||
move 2 from 2 to 8
|
||||
move 2 from 8 to 1
|
||||
move 3 from 7 to 2
|
||||
move 3 from 4 to 9
|
||||
move 18 from 1 to 8
|
||||
move 1 from 7 to 3
|
||||
move 3 from 9 to 6
|
||||
move 1 from 1 to 5
|
||||
move 5 from 6 to 4
|
||||
move 2 from 1 to 9
|
||||
move 8 from 4 to 5
|
||||
move 4 from 3 to 2
|
||||
move 16 from 5 to 4
|
||||
move 8 from 8 to 6
|
||||
move 2 from 2 to 6
|
||||
move 1 from 7 to 6
|
||||
move 7 from 8 to 1
|
||||
move 1 from 2 to 3
|
||||
move 2 from 8 to 3
|
||||
move 4 from 4 to 9
|
||||
move 4 from 1 to 2
|
||||
move 1 from 7 to 2
|
||||
move 1 from 5 to 4
|
||||
move 1 from 3 to 7
|
||||
move 3 from 4 to 5
|
||||
move 1 from 9 to 6
|
||||
move 9 from 2 to 5
|
||||
move 2 from 3 to 6
|
||||
move 3 from 5 to 8
|
||||
move 3 from 1 to 7
|
||||
move 4 from 5 to 8
|
||||
move 1 from 4 to 3
|
||||
move 5 from 9 to 5
|
||||
move 5 from 5 to 8
|
||||
move 1 from 3 to 4
|
||||
move 4 from 5 to 1
|
||||
move 2 from 5 to 4
|
||||
move 13 from 6 to 2
|
||||
move 12 from 2 to 9
|
||||
move 3 from 9 to 2
|
||||
move 4 from 1 to 6
|
||||
move 8 from 6 to 2
|
||||
move 1 from 4 to 9
|
||||
move 3 from 7 to 9
|
||||
move 2 from 9 to 8
|
||||
move 1 from 7 to 2
|
||||
move 9 from 9 to 5
|
||||
move 2 from 8 to 6
|
||||
move 4 from 2 to 3
|
||||
move 1 from 7 to 2
|
||||
move 1 from 6 to 4
|
||||
move 4 from 3 to 9
|
||||
move 9 from 5 to 8
|
||||
move 10 from 4 to 2
|
||||
move 1 from 4 to 7
|
||||
move 1 from 6 to 2
|
||||
move 1 from 6 to 7
|
||||
move 13 from 2 to 6
|
||||
move 1 from 2 to 5
|
||||
move 6 from 6 to 5
|
||||
move 7 from 5 to 8
|
||||
move 1 from 4 to 5
|
||||
move 27 from 8 to 5
|
||||
move 3 from 6 to 3
|
||||
move 2 from 8 to 6
|
||||
move 8 from 9 to 5
|
||||
move 1 from 7 to 9
|
||||
move 1 from 6 to 2
|
||||
move 4 from 5 to 9
|
||||
move 2 from 3 to 4
|
||||
move 9 from 2 to 5
|
||||
move 1 from 4 to 1
|
||||
move 1 from 4 to 2
|
||||
move 1 from 2 to 4
|
||||
move 1 from 3 to 7
|
||||
move 1 from 1 to 3
|
||||
move 1 from 3 to 9
|
||||
move 6 from 9 to 4
|
||||
move 1 from 7 to 5
|
||||
move 13 from 5 to 2
|
||||
move 1 from 9 to 5
|
||||
move 1 from 7 to 2
|
||||
move 5 from 2 to 7
|
||||
move 8 from 5 to 7
|
||||
move 6 from 4 to 2
|
||||
move 1 from 4 to 5
|
||||
move 3 from 2 to 4
|
||||
move 4 from 2 to 7
|
||||
move 2 from 4 to 3
|
||||
move 13 from 7 to 3
|
||||
move 5 from 2 to 3
|
||||
move 4 from 7 to 8
|
||||
move 11 from 3 to 8
|
||||
move 11 from 5 to 9
|
||||
move 4 from 6 to 9
|
||||
move 1 from 6 to 5
|
||||
move 1 from 4 to 2
|
||||
move 1 from 3 to 6
|
||||
move 3 from 2 to 6
|
||||
move 3 from 6 to 2
|
||||
move 1 from 6 to 1
|
||||
move 1 from 3 to 8
|
||||
move 3 from 3 to 6
|
||||
move 2 from 2 to 7
|
||||
move 4 from 3 to 9
|
||||
move 16 from 9 to 2
|
||||
move 1 from 7 to 8
|
||||
move 2 from 2 to 8
|
||||
move 9 from 2 to 3
|
||||
move 6 from 2 to 7
|
||||
move 1 from 6 to 3
|
||||
move 2 from 9 to 2
|
||||
move 1 from 9 to 7
|
||||
move 2 from 6 to 3
|
||||
move 4 from 3 to 9
|
||||
move 2 from 2 to 7
|
||||
move 1 from 2 to 5
|
||||
move 14 from 5 to 6
|
||||
move 14 from 6 to 3
|
||||
move 4 from 9 to 8
|
||||
move 5 from 8 to 4
|
||||
move 1 from 1 to 5
|
||||
move 4 from 8 to 1
|
||||
move 1 from 5 to 9
|
||||
move 8 from 7 to 2
|
||||
move 18 from 3 to 7
|
||||
move 1 from 1 to 5
|
||||
move 1 from 1 to 9
|
||||
move 1 from 4 to 5
|
||||
move 1 from 8 to 5
|
||||
move 8 from 2 to 9
|
||||
move 3 from 5 to 8
|
||||
move 7 from 7 to 1
|
||||
move 3 from 4 to 7
|
||||
move 1 from 3 to 6
|
||||
move 7 from 8 to 3
|
||||
move 2 from 9 to 3
|
||||
move 3 from 8 to 9
|
||||
move 9 from 1 to 7
|
||||
move 9 from 3 to 4
|
||||
move 2 from 3 to 4
|
||||
move 12 from 7 to 4
|
||||
move 1 from 3 to 8
|
||||
move 1 from 8 to 7
|
||||
move 8 from 4 to 7
|
||||
move 11 from 4 to 9
|
||||
move 5 from 4 to 8
|
||||
move 19 from 7 to 9
|
||||
move 1 from 6 to 2
|
||||
move 2 from 7 to 4
|
||||
move 2 from 8 to 3
|
||||
move 1 from 7 to 8
|
||||
move 1 from 3 to 2
|
||||
move 3 from 8 to 4
|
||||
move 1 from 8 to 9
|
||||
move 1 from 3 to 2
|
||||
move 36 from 9 to 1
|
||||
move 5 from 9 to 6
|
||||
move 5 from 4 to 2
|
||||
move 24 from 1 to 3
|
||||
move 5 from 6 to 7
|
||||
move 1 from 1 to 4
|
||||
move 14 from 3 to 4
|
||||
move 4 from 7 to 3
|
||||
move 1 from 8 to 5
|
||||
move 5 from 2 to 9
|
||||
move 1 from 1 to 6
|
||||
move 5 from 9 to 1
|
||||
move 3 from 2 to 3
|
||||
move 1 from 5 to 3
|
||||
move 11 from 4 to 2
|
||||
move 1 from 7 to 1
|
||||
move 6 from 1 to 9
|
||||
move 3 from 4 to 2
|
||||
move 1 from 6 to 7
|
||||
move 10 from 1 to 7
|
||||
move 3 from 2 to 1
|
||||
move 3 from 3 to 2
|
||||
move 2 from 1 to 7
|
||||
move 1 from 4 to 8
|
||||
move 13 from 3 to 2
|
||||
move 1 from 8 to 3
|
||||
move 2 from 7 to 5
|
||||
move 2 from 3 to 7
|
||||
move 2 from 5 to 2
|
||||
move 1 from 1 to 7
|
||||
move 28 from 2 to 6
|
||||
move 1 from 2 to 3
|
||||
move 2 from 8 to 2
|
||||
move 6 from 9 to 7
|
||||
move 1 from 3 to 8
|
||||
move 1 from 9 to 8
|
||||
move 3 from 6 to 2
|
||||
move 14 from 7 to 9
|
||||
move 3 from 2 to 1
|
||||
move 2 from 2 to 9
|
||||
move 2 from 1 to 9
|
||||
move 1 from 9 to 1
|
||||
move 7 from 6 to 9
|
||||
move 2 from 1 to 4
|
||||
move 2 from 4 to 6
|
||||
move 4 from 8 to 7
|
||||
move 1 from 7 to 6
|
||||
move 1 from 8 to 1
|
||||
move 1 from 3 to 6
|
||||
move 1 from 1 to 5
|
||||
move 14 from 9 to 8
|
||||
move 1 from 5 to 9
|
||||
move 5 from 7 to 3
|
||||
move 16 from 6 to 3
|
||||
move 2 from 7 to 4
|
||||
move 8 from 9 to 5
|
||||
move 6 from 6 to 1
|
||||
move 8 from 5 to 9
|
||||
move 2 from 7 to 4
|
||||
move 11 from 9 to 1
|
||||
move 4 from 4 to 1
|
||||
move 14 from 8 to 3
|
||||
move 2 from 1 to 7
|
||||
move 20 from 3 to 6
|
||||
move 5 from 3 to 1
|
||||
move 1 from 3 to 5
|
||||
move 2 from 7 to 4
|
||||
move 20 from 6 to 7
|
||||
move 18 from 7 to 6
|
||||
move 17 from 6 to 9
|
||||
move 1 from 5 to 3
|
||||
move 6 from 3 to 2
|
||||
move 3 from 3 to 1
|
||||
move 1 from 6 to 2
|
||||
move 2 from 7 to 8
|
||||
move 4 from 1 to 5
|
||||
move 2 from 4 to 9
|
||||
move 1 from 3 to 2
|
||||
move 1 from 8 to 6
|
||||
move 18 from 1 to 4
|
||||
move 1 from 2 to 7
|
||||
move 1 from 6 to 2
|
||||
move 3 from 4 to 3
|
||||
move 1 from 8 to 1
|
||||
move 4 from 1 to 6
|
||||
move 7 from 2 to 1
|
||||
move 1 from 5 to 7
|
||||
move 1 from 4 to 1
|
||||
move 2 from 6 to 3
|
||||
move 3 from 5 to 9
|
||||
move 9 from 9 to 8
|
||||
move 10 from 9 to 3
|
||||
move 9 from 3 to 5
|
9
2022/day05-supply_stacks/tests/sample_input
Normal file
9
2022/day05-supply_stacks/tests/sample_input
Normal file
|
@ -0,0 +1,9 @@
|
|||
[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
|
Loading…
Add table
Add a link
Reference in a new issue