day 5
This commit is contained in:
parent
c67298eb5a
commit
87f14bbf0c
8
day5/Cargo.toml
Normal file
8
day5/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "day5"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
511
day5/input.txt
Normal file
511
day5/input.txt
Normal file
@ -0,0 +1,511 @@
|
|||||||
|
[Q] [J] [H]
|
||||||
|
[G] [S] [Q] [Z] [P]
|
||||||
|
[P] [F] [M] [F] [F] [S]
|
||||||
|
[R] [R] [P] [F] [V] [D] [L]
|
||||||
|
[L] [W] [W] [D] [W] [S] [V] [G]
|
||||||
|
[C] [H] [H] [T] [D] [L] [M] [B] [B]
|
||||||
|
[T] [Q] [B] [S] [L] [C] [B] [J] [N]
|
||||||
|
[F] [N] [F] [V] [Q] [Z] [Z] [T] [Q]
|
||||||
|
1 2 3 4 5 6 7 8 9
|
||||||
|
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 1 from 6 to 1
|
||||||
|
move 3 from 7 to 4
|
||||||
|
move 3 from 2 to 9
|
||||||
|
move 11 from 9 to 3
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 15 from 3 to 9
|
||||||
|
move 5 from 2 to 3
|
||||||
|
move 3 from 7 to 5
|
||||||
|
move 6 from 9 to 3
|
||||||
|
move 6 from 1 to 6
|
||||||
|
move 2 from 3 to 7
|
||||||
|
move 5 from 4 to 5
|
||||||
|
move 7 from 9 to 4
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 10 from 4 to 2
|
||||||
|
move 6 from 5 to 4
|
||||||
|
move 2 from 7 to 6
|
||||||
|
move 10 from 2 to 3
|
||||||
|
move 21 from 3 to 5
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 3 from 6 to 9
|
||||||
|
move 1 from 8 to 9
|
||||||
|
move 5 from 4 to 5
|
||||||
|
move 4 from 9 to 3
|
||||||
|
move 17 from 5 to 1
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 16 from 5 to 1
|
||||||
|
move 3 from 3 to 6
|
||||||
|
move 6 from 6 to 4
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 4 from 1 to 2
|
||||||
|
move 2 from 6 to 2
|
||||||
|
move 28 from 1 to 3
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 1 from 3 to 1
|
||||||
|
move 3 from 2 to 5
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 4 from 4 to 7
|
||||||
|
move 5 from 5 to 2
|
||||||
|
move 1 from 5 to 6
|
||||||
|
move 6 from 1 to 3
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 26 from 3 to 6
|
||||||
|
move 2 from 7 to 9
|
||||||
|
move 4 from 7 to 3
|
||||||
|
move 19 from 6 to 3
|
||||||
|
move 6 from 2 to 4
|
||||||
|
move 5 from 3 to 2
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 26 from 3 to 8
|
||||||
|
move 6 from 4 to 3
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 6 from 3 to 6
|
||||||
|
move 6 from 6 to 4
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 22 from 8 to 2
|
||||||
|
move 2 from 6 to 5
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 3 from 6 to 7
|
||||||
|
move 2 from 6 to 1
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 3 from 5 to 9
|
||||||
|
move 4 from 8 to 4
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 18 from 2 to 1
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 3 from 9 to 5
|
||||||
|
move 8 from 1 to 9
|
||||||
|
move 5 from 9 to 3
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 5 from 5 to 7
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 4 from 8 to 4
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 4 from 4 to 3
|
||||||
|
move 2 from 8 to 3
|
||||||
|
move 1 from 8 to 9
|
||||||
|
move 2 from 1 to 8
|
||||||
|
move 3 from 4 to 5
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 8 from 1 to 8
|
||||||
|
move 11 from 2 to 9
|
||||||
|
move 12 from 3 to 5
|
||||||
|
move 1 from 3 to 9
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 11 from 9 to 3
|
||||||
|
move 4 from 5 to 9
|
||||||
|
move 3 from 8 to 7
|
||||||
|
move 3 from 7 to 8
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 7 from 4 to 3
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 2 to 8
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 3 from 4 to 8
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 2 from 4 to 7
|
||||||
|
move 5 from 8 to 1
|
||||||
|
move 3 from 6 to 5
|
||||||
|
move 2 from 4 to 2
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 3 from 8 to 4
|
||||||
|
move 3 from 4 to 2
|
||||||
|
move 4 from 3 to 9
|
||||||
|
move 17 from 5 to 9
|
||||||
|
move 9 from 9 to 6
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 5 from 6 to 3
|
||||||
|
move 3 from 6 to 3
|
||||||
|
move 8 from 9 to 5
|
||||||
|
move 2 from 8 to 5
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 3 from 2 to 6
|
||||||
|
move 3 from 1 to 4
|
||||||
|
move 7 from 5 to 1
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 13 from 3 to 6
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 13 from 6 to 5
|
||||||
|
move 3 from 5 to 7
|
||||||
|
move 6 from 5 to 6
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 2 from 7 to 3
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 13 from 3 to 5
|
||||||
|
move 9 from 5 to 9
|
||||||
|
move 7 from 5 to 7
|
||||||
|
move 17 from 9 to 2
|
||||||
|
move 3 from 4 to 7
|
||||||
|
move 9 from 2 to 9
|
||||||
|
move 10 from 9 to 3
|
||||||
|
move 8 from 7 to 8
|
||||||
|
move 2 from 5 to 3
|
||||||
|
move 4 from 2 to 6
|
||||||
|
move 11 from 3 to 9
|
||||||
|
move 9 from 6 to 5
|
||||||
|
move 5 from 9 to 8
|
||||||
|
move 1 from 3 to 1
|
||||||
|
move 3 from 9 to 1
|
||||||
|
move 2 from 5 to 2
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 2 from 9 to 8
|
||||||
|
move 13 from 1 to 8
|
||||||
|
move 3 from 8 to 5
|
||||||
|
move 27 from 8 to 1
|
||||||
|
move 10 from 5 to 9
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 10 from 9 to 6
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 15 from 1 to 9
|
||||||
|
move 13 from 9 to 5
|
||||||
|
move 15 from 5 to 7
|
||||||
|
move 5 from 1 to 3
|
||||||
|
move 8 from 7 to 1
|
||||||
|
move 7 from 7 to 1
|
||||||
|
move 16 from 1 to 8
|
||||||
|
move 4 from 3 to 9
|
||||||
|
move 4 from 1 to 7
|
||||||
|
move 4 from 9 to 6
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 15 from 8 to 6
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 3 from 3 to 4
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 3 from 4 to 8
|
||||||
|
move 3 from 8 to 1
|
||||||
|
move 8 from 6 to 8
|
||||||
|
move 7 from 1 to 4
|
||||||
|
move 11 from 6 to 8
|
||||||
|
move 14 from 6 to 5
|
||||||
|
move 13 from 8 to 7
|
||||||
|
move 4 from 7 to 5
|
||||||
|
move 15 from 7 to 4
|
||||||
|
move 6 from 5 to 4
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 3 from 8 to 5
|
||||||
|
move 19 from 4 to 7
|
||||||
|
move 10 from 5 to 8
|
||||||
|
move 2 from 6 to 8
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 2 from 7 to 9
|
||||||
|
move 9 from 7 to 4
|
||||||
|
move 6 from 4 to 6
|
||||||
|
move 11 from 4 to 8
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 5 from 6 to 4
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 3 from 9 to 5
|
||||||
|
move 3 from 8 to 5
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 11 from 8 to 7
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 5 from 4 to 9
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 4 from 5 to 1
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 17 from 7 to 5
|
||||||
|
move 9 from 8 to 7
|
||||||
|
move 6 from 9 to 7
|
||||||
|
move 3 from 1 to 9
|
||||||
|
move 12 from 7 to 9
|
||||||
|
move 12 from 9 to 5
|
||||||
|
move 5 from 7 to 9
|
||||||
|
move 17 from 5 to 3
|
||||||
|
move 7 from 3 to 1
|
||||||
|
move 5 from 1 to 5
|
||||||
|
move 5 from 9 to 2
|
||||||
|
move 4 from 3 to 5
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 5 from 2 to 1
|
||||||
|
move 22 from 5 to 9
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 6 from 6 to 9
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 1 from 3 to 4
|
||||||
|
move 24 from 9 to 1
|
||||||
|
move 4 from 3 to 9
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 1 from 8 to 9
|
||||||
|
move 2 from 7 to 4
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 1 from 4 to 7
|
||||||
|
move 3 from 9 to 8
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 9 from 9 to 3
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 2 from 9 to 7
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 2 from 8 to 4
|
||||||
|
move 12 from 3 to 8
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 30 from 1 to 5
|
||||||
|
move 6 from 5 to 7
|
||||||
|
move 12 from 7 to 2
|
||||||
|
move 1 from 3 to 4
|
||||||
|
move 2 from 1 to 3
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 10 from 5 to 7
|
||||||
|
move 10 from 2 to 6
|
||||||
|
move 8 from 8 to 3
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 5 from 6 to 3
|
||||||
|
move 2 from 8 to 5
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 2 from 8 to 6
|
||||||
|
move 4 from 7 to 2
|
||||||
|
move 3 from 2 to 7
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 11 from 3 to 1
|
||||||
|
move 7 from 6 to 9
|
||||||
|
move 3 from 2 to 3
|
||||||
|
move 10 from 1 to 7
|
||||||
|
move 14 from 7 to 5
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 5 from 9 to 7
|
||||||
|
move 29 from 5 to 7
|
||||||
|
move 6 from 3 to 9
|
||||||
|
move 2 from 9 to 7
|
||||||
|
move 15 from 7 to 5
|
||||||
|
move 11 from 5 to 6
|
||||||
|
move 5 from 9 to 5
|
||||||
|
move 10 from 5 to 8
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 8 from 8 to 9
|
||||||
|
move 11 from 9 to 3
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 18 from 7 to 3
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 28 from 3 to 5
|
||||||
|
move 12 from 6 to 7
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 15 from 7 to 2
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 10 from 2 to 9
|
||||||
|
move 10 from 5 to 3
|
||||||
|
move 2 from 2 to 3
|
||||||
|
move 18 from 3 to 4
|
||||||
|
move 6 from 9 to 4
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 1 from 6 to 4
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 19 from 4 to 3
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 3 from 2 to 8
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 15 from 3 to 1
|
||||||
|
move 7 from 5 to 1
|
||||||
|
move 3 from 4 to 9
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 6 from 5 to 2
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 4 from 9 to 2
|
||||||
|
move 5 from 5 to 3
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 3 from 5 to 7
|
||||||
|
move 3 from 8 to 5
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 4 from 5 to 1
|
||||||
|
move 4 from 4 to 2
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 12 from 1 to 6
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 6 from 2 to 3
|
||||||
|
move 9 from 3 to 8
|
||||||
|
move 1 from 3 to 4
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 2 from 9 to 2
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 2 from 8 to 3
|
||||||
|
move 10 from 2 to 1
|
||||||
|
move 2 from 4 to 7
|
||||||
|
move 12 from 1 to 4
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 7 from 4 to 9
|
||||||
|
move 2 from 3 to 2
|
||||||
|
move 6 from 9 to 2
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 5 from 6 to 7
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 6 from 2 to 3
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 8 from 3 to 9
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 10 from 8 to 2
|
||||||
|
move 22 from 1 to 9
|
||||||
|
move 9 from 2 to 4
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 2 from 7 to 1
|
||||||
|
move 14 from 4 to 2
|
||||||
|
move 2 from 1 to 8
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 4 from 7 to 8
|
||||||
|
move 24 from 9 to 6
|
||||||
|
move 3 from 5 to 9
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 6 from 9 to 1
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 5 from 8 to 6
|
||||||
|
move 9 from 6 to 3
|
||||||
|
move 4 from 1 to 4
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 11 from 6 to 3
|
||||||
|
move 13 from 3 to 2
|
||||||
|
move 2 from 9 to 8
|
||||||
|
move 8 from 3 to 8
|
||||||
|
move 2 from 8 to 5
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 3 from 6 to 3
|
||||||
|
move 11 from 8 to 5
|
||||||
|
move 13 from 2 to 4
|
||||||
|
move 10 from 5 to 2
|
||||||
|
move 2 from 3 to 4
|
||||||
|
move 2 from 5 to 7
|
||||||
|
move 15 from 4 to 9
|
||||||
|
move 2 from 7 to 4
|
||||||
|
move 2 from 4 to 2
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 2 from 4 to 2
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 7 from 2 to 4
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 7 from 9 to 1
|
||||||
|
move 7 from 1 to 2
|
||||||
|
move 4 from 6 to 9
|
||||||
|
move 12 from 9 to 7
|
||||||
|
move 6 from 7 to 5
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 7 from 4 to 7
|
||||||
|
move 3 from 7 to 8
|
||||||
|
move 3 from 8 to 6
|
||||||
|
move 18 from 2 to 9
|
||||||
|
move 7 from 2 to 3
|
||||||
|
move 15 from 9 to 4
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 1 from 3 to 1
|
||||||
|
move 3 from 5 to 4
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 2 from 6 to 2
|
||||||
|
move 5 from 7 to 6
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 3 from 3 to 4
|
||||||
|
move 5 from 5 to 3
|
||||||
|
move 6 from 7 to 4
|
||||||
|
move 9 from 4 to 2
|
||||||
|
move 18 from 4 to 9
|
||||||
|
move 6 from 2 to 1
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 4 from 7 to 4
|
||||||
|
move 7 from 2 to 4
|
||||||
|
move 1 from 2 to 8
|
||||||
|
move 1 from 4 to 2
|
||||||
|
move 4 from 3 to 4
|
||||||
|
move 16 from 9 to 5
|
||||||
|
move 9 from 9 to 8
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 4 from 1 to 2
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 10 from 5 to 4
|
||||||
|
move 4 from 2 to 1
|
||||||
|
move 5 from 1 to 2
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 4 from 8 to 5
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 3 from 6 to 2
|
||||||
|
move 2 from 9 to 1
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 9 from 5 to 9
|
||||||
|
move 4 from 8 to 1
|
||||||
|
move 2 from 8 to 2
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 9 from 9 to 8
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 9 from 8 to 2
|
||||||
|
move 6 from 1 to 6
|
||||||
|
move 6 from 2 to 6
|
||||||
|
move 10 from 2 to 5
|
||||||
|
move 5 from 2 to 1
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 8 from 5 to 4
|
||||||
|
move 5 from 1 to 3
|
||||||
|
move 10 from 6 to 8
|
||||||
|
move 3 from 6 to 9
|
||||||
|
move 4 from 3 to 1
|
||||||
|
move 5 from 8 to 2
|
||||||
|
move 4 from 5 to 9
|
||||||
|
move 1 from 3 to 7
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 6 to 1
|
||||||
|
move 15 from 4 to 8
|
||||||
|
move 5 from 9 to 2
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 6 from 4 to 8
|
||||||
|
move 12 from 8 to 7
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 3 from 1 to 9
|
||||||
|
move 13 from 4 to 9
|
||||||
|
move 5 from 7 to 2
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 8 from 9 to 5
|
||||||
|
move 6 from 2 to 5
|
||||||
|
move 2 from 5 to 6
|
9
day5/sample_input.txt
Normal file
9
day5/sample_input.txt
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
|
75
day5/src/main.rs
Normal file
75
day5/src/main.rs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
fn print_stacks(stacks: &Vec<Vec<char>>) {
|
||||||
|
for stack in stacks {
|
||||||
|
println!("{:?}", stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stacks_message(stacks: &Vec<Vec<char>>) -> String {
|
||||||
|
stacks.iter().map(|v| {
|
||||||
|
v[v.len() - 1]
|
||||||
|
}).fold(String::new(), |mut s, c| {
|
||||||
|
s.push(c);
|
||||||
|
s
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
const INPUT: &str = include_str!("../input.txt");
|
||||||
|
let chunks = INPUT.split_once("\n\n").unwrap();
|
||||||
|
|
||||||
|
let mut stack_lines: Vec<String> = chunks.0.lines().map(|x| -> String {
|
||||||
|
x.to_string() + " "
|
||||||
|
}).collect();
|
||||||
|
stack_lines.pop();
|
||||||
|
let num_stacks = (stack_lines[0].len() + 1) / 4;
|
||||||
|
|
||||||
|
let mut stacks: Vec<Vec<char>> = vec![Vec::<char>::new(); num_stacks];
|
||||||
|
|
||||||
|
for line in stack_lines.iter().rev() {
|
||||||
|
let mut line = line.to_string();
|
||||||
|
line += " ";
|
||||||
|
|
||||||
|
for i in 0..num_stacks {
|
||||||
|
let c = line.chars().nth(i*4 + 1).unwrap();
|
||||||
|
if c.is_whitespace() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stacks[i].push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let stacks_copy = stacks.clone();
|
||||||
|
|
||||||
|
let move_lines = chunks.1.lines();
|
||||||
|
for line in move_lines {
|
||||||
|
let split: Vec<&str> = line.split(" ").collect();
|
||||||
|
let n: usize = split[1].parse().unwrap();
|
||||||
|
let from = split[3].parse::<usize>().unwrap() - 1;
|
||||||
|
let to = split[5].parse::<usize>().unwrap() - 1;
|
||||||
|
|
||||||
|
for _ in 0..n {
|
||||||
|
let x = stacks[from].pop().unwrap();
|
||||||
|
stacks[to].push(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_stacks(&stacks);
|
||||||
|
println!("Message: {}\n", stacks_message(&stacks));
|
||||||
|
|
||||||
|
let mut stacks = stacks_copy;
|
||||||
|
let move_lines = chunks.1.lines();
|
||||||
|
for line in move_lines {
|
||||||
|
let split: Vec<&str> = line.split(" ").collect();
|
||||||
|
let n: usize = split[1].parse().unwrap();
|
||||||
|
let from = split[3].parse::<usize>().unwrap() - 1;
|
||||||
|
let to = split[5].parse::<usize>().unwrap() - 1;
|
||||||
|
|
||||||
|
let len = stacks[from].len();
|
||||||
|
let mut x: Vec<char> = stacks[from].drain(len-n..len).collect();
|
||||||
|
stacks[to].append(x.as_mut());
|
||||||
|
}
|
||||||
|
|
||||||
|
print_stacks(&stacks);
|
||||||
|
println!("Message: {}", stacks_message(&stacks));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user