day 05
This commit is contained in:
parent
25eb59e2f1
commit
44a0e91b7d
|
@ -0,0 +1,12 @@
|
||||||
|
# ---> Rust
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "aoc_05a"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
|
@ -0,0 +1,514 @@
|
||||||
|
[V] [B] [F]
|
||||||
|
[N] [Q] [W] [R] [B]
|
||||||
|
[F] [D] [S] [B] [L] [P]
|
||||||
|
[S] [J] [C] [F] [C] [D] [G]
|
||||||
|
[M] [M] [H] [L] [P] [N] [P] [V]
|
||||||
|
[P] [L] [D] [C] [T] [Q] [R] [S] [J]
|
||||||
|
[H] [R] [Q] [S] [V] [R] [V] [Z] [S]
|
||||||
|
[J] [S] [N] [R] [M] [T] [G] [C] [D]
|
||||||
|
1 2 3 4 5 6 7 8 9
|
||||||
|
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 2 from 6 to 5
|
||||||
|
move 8 from 5 to 1
|
||||||
|
move 5 from 3 to 8
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 8 from 1 to 2
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 13 from 8 to 7
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 4 from 4 to 2
|
||||||
|
move 10 from 9 to 4
|
||||||
|
move 7 from 4 to 1
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 3 from 1 to 5
|
||||||
|
move 2 from 4 to 6
|
||||||
|
move 2 from 6 to 4
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 5 from 1 to 5
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 14 from 2 to 6
|
||||||
|
move 12 from 7 to 4
|
||||||
|
move 4 from 6 to 7
|
||||||
|
move 3 from 6 to 4
|
||||||
|
move 4 from 4 to 9
|
||||||
|
move 2 from 4 to 6
|
||||||
|
move 2 from 9 to 3
|
||||||
|
move 9 from 4 to 3
|
||||||
|
move 2 from 1 to 6
|
||||||
|
move 5 from 7 to 3
|
||||||
|
move 4 from 7 to 8
|
||||||
|
move 2 from 6 to 7
|
||||||
|
move 3 from 6 to 7
|
||||||
|
move 10 from 5 to 8
|
||||||
|
move 8 from 8 to 9
|
||||||
|
move 10 from 9 to 7
|
||||||
|
move 12 from 7 to 5
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 3 from 7 to 2
|
||||||
|
move 10 from 3 to 7
|
||||||
|
move 6 from 5 to 7
|
||||||
|
move 2 from 6 to 1
|
||||||
|
move 12 from 2 to 7
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 10 from 5 to 7
|
||||||
|
move 3 from 3 to 4
|
||||||
|
move 34 from 7 to 1
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 3 from 3 to 6
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 22 from 1 to 6
|
||||||
|
move 2 from 9 to 7
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 12 from 6 to 8
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 4 from 8 to 2
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 6 from 8 to 9
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 13 from 1 to 2
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 4 from 7 to 5
|
||||||
|
move 3 from 9 to 4
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 4 from 5 to 2
|
||||||
|
move 12 from 6 to 2
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 9 from 8 to 5
|
||||||
|
move 6 from 5 to 7
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 5 from 9 to 6
|
||||||
|
move 5 from 3 to 7
|
||||||
|
move 30 from 2 to 6
|
||||||
|
move 11 from 7 to 9
|
||||||
|
move 36 from 6 to 3
|
||||||
|
move 10 from 9 to 3
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 3 from 5 to 2
|
||||||
|
move 2 from 5 to 2
|
||||||
|
move 28 from 3 to 4
|
||||||
|
move 6 from 4 to 1
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 2 from 5 to 2
|
||||||
|
move 6 from 1 to 7
|
||||||
|
move 1 from 1 to 6
|
||||||
|
move 6 from 3 to 5
|
||||||
|
move 6 from 7 to 2
|
||||||
|
move 1 from 6 to 4
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 8 from 2 to 1
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 2 from 3 to 4
|
||||||
|
move 4 from 3 to 4
|
||||||
|
move 1 from 6 to 1
|
||||||
|
move 2 from 1 to 8
|
||||||
|
move 1 from 6 to 4
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 34 from 4 to 9
|
||||||
|
move 13 from 9 to 8
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 4 from 5 to 1
|
||||||
|
move 9 from 8 to 7
|
||||||
|
move 11 from 1 to 3
|
||||||
|
move 1 from 4 to 2
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 5 from 7 to 8
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 21 from 9 to 5
|
||||||
|
move 19 from 3 to 4
|
||||||
|
move 17 from 4 to 6
|
||||||
|
move 2 from 8 to 4
|
||||||
|
move 2 from 6 to 8
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 2 from 7 to 6
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 6 from 5 to 6
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 8 from 5 to 7
|
||||||
|
move 15 from 6 to 2
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 2 from 1 to 6
|
||||||
|
move 3 from 4 to 7
|
||||||
|
move 1 from 1 to 6
|
||||||
|
move 3 from 5 to 4
|
||||||
|
move 2 from 5 to 6
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 13 from 7 to 8
|
||||||
|
move 2 from 6 to 4
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 2 from 7 to 6
|
||||||
|
move 5 from 4 to 6
|
||||||
|
move 4 from 2 to 6
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 18 from 8 to 3
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 15 from 3 to 1
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 3 from 3 to 4
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 1 from 5 to 6
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 2 from 8 to 2
|
||||||
|
move 3 from 1 to 8
|
||||||
|
move 6 from 2 to 8
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 12 from 8 to 5
|
||||||
|
move 2 from 9 to 6
|
||||||
|
move 6 from 1 to 5
|
||||||
|
move 9 from 5 to 3
|
||||||
|
move 1 from 2 to 8
|
||||||
|
move 20 from 6 to 9
|
||||||
|
move 3 from 6 to 7
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 7 from 3 to 4
|
||||||
|
move 2 from 7 to 2
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 8 from 4 to 1
|
||||||
|
move 11 from 1 to 7
|
||||||
|
move 10 from 7 to 6
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 21 from 9 to 3
|
||||||
|
move 6 from 5 to 9
|
||||||
|
move 6 from 3 to 2
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 8 from 3 to 2
|
||||||
|
move 9 from 2 to 1
|
||||||
|
move 14 from 1 to 6
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 4 from 3 to 8
|
||||||
|
move 3 from 8 to 7
|
||||||
|
move 5 from 7 to 4
|
||||||
|
move 3 from 6 to 9
|
||||||
|
move 2 from 3 to 7
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 1 from 5 to 6
|
||||||
|
move 2 from 7 to 9
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 22 from 6 to 5
|
||||||
|
move 3 from 9 to 4
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 5 from 4 to 6
|
||||||
|
move 9 from 2 to 8
|
||||||
|
move 4 from 6 to 1
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 6 from 8 to 1
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 10 from 1 to 7
|
||||||
|
move 2 from 8 to 7
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 4 from 3 to 5
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 4 from 9 to 8
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 10 from 5 to 9
|
||||||
|
move 5 from 6 to 4
|
||||||
|
move 5 from 8 to 5
|
||||||
|
move 4 from 9 to 8
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 2 from 8 to 6
|
||||||
|
move 5 from 7 to 5
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 2 from 8 to 6
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 28 from 5 to 9
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 3 from 1 to 9
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 15 from 9 to 2
|
||||||
|
move 11 from 9 to 4
|
||||||
|
move 11 from 4 to 7
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 7 from 7 to 8
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 20 from 9 to 1
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 4 from 5 to 2
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 11 from 8 to 3
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 4 from 9 to 8
|
||||||
|
move 4 from 8 to 7
|
||||||
|
move 10 from 1 to 6
|
||||||
|
move 7 from 1 to 5
|
||||||
|
move 8 from 3 to 4
|
||||||
|
move 2 from 3 to 5
|
||||||
|
move 3 from 7 to 4
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 2 from 1 to 6
|
||||||
|
move 9 from 2 to 6
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 7 from 4 to 3
|
||||||
|
move 3 from 3 to 7
|
||||||
|
move 5 from 2 to 3
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 2 from 2 to 7
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 4 from 7 to 6
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 1 from 4 to 7
|
||||||
|
move 1 from 2 to 8
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 27 from 6 to 2
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 7 from 5 to 7
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 3 from 7 to 3
|
||||||
|
move 2 from 1 to 6
|
||||||
|
move 2 from 9 to 1
|
||||||
|
move 18 from 2 to 1
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 12 from 3 to 4
|
||||||
|
move 1 from 5 to 6
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 24 from 1 to 8
|
||||||
|
move 9 from 2 to 4
|
||||||
|
move 3 from 2 to 1
|
||||||
|
move 2 from 6 to 3
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 1 from 5 to 6
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 3 from 7 to 2
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 8 from 4 to 5
|
||||||
|
move 22 from 8 to 1
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 13 from 4 to 1
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 38 from 1 to 6
|
||||||
|
move 27 from 6 to 1
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 3 from 9 to 8
|
||||||
|
move 2 from 8 to 6
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 7 from 6 to 3
|
||||||
|
move 20 from 1 to 4
|
||||||
|
move 6 from 1 to 6
|
||||||
|
move 17 from 4 to 7
|
||||||
|
move 3 from 6 to 5
|
||||||
|
move 14 from 7 to 9
|
||||||
|
move 8 from 5 to 7
|
||||||
|
move 3 from 1 to 6
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 4 from 5 to 1
|
||||||
|
move 9 from 6 to 2
|
||||||
|
move 3 from 6 to 4
|
||||||
|
move 4 from 7 to 8
|
||||||
|
move 4 from 1 to 6
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 6 from 6 to 7
|
||||||
|
move 4 from 8 to 7
|
||||||
|
move 4 from 2 to 1
|
||||||
|
move 4 from 2 to 3
|
||||||
|
move 4 from 9 to 5
|
||||||
|
move 8 from 9 to 5
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 16 from 7 to 2
|
||||||
|
move 10 from 2 to 9
|
||||||
|
move 11 from 9 to 8
|
||||||
|
move 4 from 3 to 5
|
||||||
|
move 3 from 1 to 4
|
||||||
|
move 13 from 5 to 7
|
||||||
|
move 10 from 8 to 5
|
||||||
|
move 2 from 1 to 5
|
||||||
|
move 11 from 7 to 4
|
||||||
|
move 2 from 3 to 6
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 2 from 8 to 4
|
||||||
|
move 3 from 1 to 2
|
||||||
|
move 4 from 6 to 1
|
||||||
|
move 7 from 1 to 9
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 2 from 5 to 8
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 5 from 5 to 8
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 4 from 2 to 5
|
||||||
|
move 17 from 4 to 1
|
||||||
|
move 10 from 5 to 9
|
||||||
|
move 2 from 4 to 2
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 1 from 3 to 7
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 12 from 9 to 2
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 1 from 4 to 1
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 8 from 8 to 3
|
||||||
|
move 2 from 5 to 1
|
||||||
|
move 3 from 1 to 9
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 4 from 3 to 7
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 10 from 9 to 2
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 17 from 1 to 6
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 11 from 6 to 7
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 12 from 7 to 9
|
||||||
|
move 20 from 2 to 7
|
||||||
|
move 5 from 9 to 5
|
||||||
|
move 21 from 7 to 1
|
||||||
|
move 2 from 6 to 4
|
||||||
|
move 11 from 1 to 4
|
||||||
|
move 5 from 4 to 6
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 5 from 9 to 3
|
||||||
|
move 5 from 2 to 8
|
||||||
|
move 3 from 9 to 3
|
||||||
|
move 2 from 8 to 7
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 10 from 6 to 3
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 2 from 8 to 5
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 8 from 1 to 6
|
||||||
|
move 4 from 4 to 8
|
||||||
|
move 6 from 8 to 4
|
||||||
|
move 21 from 3 to 9
|
||||||
|
move 5 from 9 to 2
|
||||||
|
move 4 from 7 to 9
|
||||||
|
move 22 from 9 to 3
|
||||||
|
move 9 from 6 to 4
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 2 from 2 to 1
|
||||||
|
move 2 from 5 to 7
|
||||||
|
move 7 from 5 to 4
|
||||||
|
move 22 from 4 to 2
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 16 from 2 to 5
|
||||||
|
move 2 from 6 to 2
|
||||||
|
move 13 from 3 to 4
|
||||||
|
move 5 from 5 to 7
|
||||||
|
move 15 from 4 to 7
|
||||||
|
move 3 from 2 to 3
|
||||||
|
move 3 from 2 to 5
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 6 from 5 to 9
|
||||||
|
move 4 from 3 to 6
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 19 from 7 to 8
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 5 from 8 to 1
|
||||||
|
move 3 from 8 to 1
|
||||||
|
move 7 from 5 to 6
|
||||||
|
move 3 from 7 to 1
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 4 from 9 to 8
|
||||||
|
move 2 from 5 to 6
|
||||||
|
move 10 from 1 to 4
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 6 from 3 to 4
|
||||||
|
move 9 from 4 to 3
|
||||||
|
move 2 from 2 to 8
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 5 from 8 to 3
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 2 from 5 to 6
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 2 from 9 to 7
|
||||||
|
move 8 from 4 to 7
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 4 from 6 to 3
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 10 from 7 to 4
|
||||||
|
move 10 from 4 to 1
|
||||||
|
move 10 from 1 to 8
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 11 from 8 to 1
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 5 from 6 to 3
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 4 from 1 to 3
|
||||||
|
move 5 from 3 to 8
|
||||||
|
move 1 from 4 to 7
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 13 from 3 to 5
|
||||||
|
move 2 from 2 to 1
|
||||||
|
move 4 from 3 to 1
|
||||||
|
move 4 from 5 to 6
|
||||||
|
move 3 from 6 to 2
|
||||||
|
move 4 from 5 to 4
|
||||||
|
move 8 from 8 to 7
|
||||||
|
move 1 from 3 to 9
|
|
@ -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
|
|
@ -0,0 +1,76 @@
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{self, BufRead};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn prep_array(result: &mut Vec<Vec<char>>, line: String) {
|
||||||
|
for (i, c) in line.chars().enumerate() {
|
||||||
|
if i % 4 == 1 && c.is_alphabetic() {
|
||||||
|
while 1 + i / 4 > result.len() {
|
||||||
|
result.push(Vec::<char>::new());
|
||||||
|
}
|
||||||
|
result[i / 4].insert(0 , c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_array(result: &mut Vec<Vec<char>>, line: String) {
|
||||||
|
let mut cnt: usize = 0;
|
||||||
|
let mut src: usize = 0;
|
||||||
|
for (i, token) in line.split(" ").enumerate() {
|
||||||
|
match i {
|
||||||
|
1 => cnt = token.parse().unwrap(),
|
||||||
|
3 => src = token.parse().unwrap(),
|
||||||
|
5 => {
|
||||||
|
src -= 1;
|
||||||
|
let mut dst: usize = token.parse().unwrap();
|
||||||
|
dst -= 1;
|
||||||
|
let mut j = result[src].len() - 1;
|
||||||
|
for _k in 0..cnt {
|
||||||
|
let mem = result[src][j];
|
||||||
|
result[src].pop();
|
||||||
|
result[dst].push(mem);
|
||||||
|
if j > 0 {
|
||||||
|
j -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_05a/input");
|
||||||
|
let mut result = Vec::<Vec<char>>::new();
|
||||||
|
|
||||||
|
println!("In file {}", file_path);
|
||||||
|
|
||||||
|
if let Ok(lines) = read_lines(file_path) {
|
||||||
|
// Consumes the iterator, returns an (Optional) String
|
||||||
|
for line in lines {
|
||||||
|
if let Ok(ip) = line {
|
||||||
|
if ip.len() > 0 {
|
||||||
|
match &ip[..1] {
|
||||||
|
"[" => prep_array(&mut result, ip),
|
||||||
|
" " => prep_array(&mut result, ip),
|
||||||
|
"m" => move_array(&mut result, ip),
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut res = String::from("");
|
||||||
|
for i in 0..result.len() {
|
||||||
|
res.push(result[i][result[i].len() - 1]);
|
||||||
|
}
|
||||||
|
println!("{}", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
||||||
|
where P: AsRef<Path>, {
|
||||||
|
let file = File::open(filename)?;
|
||||||
|
Ok(io::BufReader::new(file).lines())
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
# ---> Rust
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "aoc_05b"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
|
@ -0,0 +1,75 @@
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{self, BufRead};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn prep_array(result: &mut Vec<Vec<char>>, line: String) {
|
||||||
|
for (i, c) in line.chars().enumerate() {
|
||||||
|
if i % 4 == 1 && c.is_alphabetic() {
|
||||||
|
while 1 + i / 4 > result.len() {
|
||||||
|
result.push(Vec::<char>::new());
|
||||||
|
}
|
||||||
|
result[i / 4].insert(0 , c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_array(result: &mut Vec<Vec<char>>, line: String) {
|
||||||
|
let mut cnt: usize = 0;
|
||||||
|
let mut src: usize = 0;
|
||||||
|
for (i, token) in line.split(" ").enumerate() {
|
||||||
|
match i {
|
||||||
|
1 => cnt = token.parse().unwrap(),
|
||||||
|
3 => src = token.parse().unwrap(),
|
||||||
|
5 => {
|
||||||
|
src -= 1;
|
||||||
|
let mut dst: usize = token.parse().unwrap();
|
||||||
|
dst -= 1;
|
||||||
|
let j = result[src].len() - 1;
|
||||||
|
for k in 0..cnt {
|
||||||
|
let mem = result[src][j - (cnt - k - 1)];
|
||||||
|
result[dst].push(mem);
|
||||||
|
}
|
||||||
|
for _k in 0..cnt {
|
||||||
|
result[src].pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_05a/input");
|
||||||
|
let mut result = Vec::<Vec<char>>::new();
|
||||||
|
|
||||||
|
println!("In file {}", file_path);
|
||||||
|
|
||||||
|
if let Ok(lines) = read_lines(file_path) {
|
||||||
|
// Consumes the iterator, returns an (Optional) String
|
||||||
|
for line in lines {
|
||||||
|
if let Ok(ip) = line {
|
||||||
|
if ip.len() > 0 {
|
||||||
|
match &ip[..1] {
|
||||||
|
"[" => prep_array(&mut result, ip),
|
||||||
|
" " => prep_array(&mut result, ip),
|
||||||
|
"m" => move_array(&mut result, ip),
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut res = String::from("");
|
||||||
|
for i in 0..result.len() {
|
||||||
|
res.push(result[i][result[i].len() - 1]);
|
||||||
|
}
|
||||||
|
println!("{}", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
||||||
|
where P: AsRef<Path>, {
|
||||||
|
let file = File::open(filename)?;
|
||||||
|
Ok(io::BufReader::new(file).lines())
|
||||||
|
}
|
Loading…
Reference in New Issue