Compare commits
2 commits
2c13f3de57
...
d75c49e8c4
Author | SHA1 | Date | |
---|---|---|---|
d75c49e8c4 | |||
a000a1a7ea |
6 changed files with 653 additions and 0 deletions
2
2022/data/day5.expected
Normal file
2
2022/data/day5.expected
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
NTWZZWHFV
|
||||||
|
BRZGFVBTJ
|
512
2022/data/day5.input
Normal file
512
2022/data/day5.input
Normal file
|
@ -0,0 +1,512 @@
|
||||||
|
[M] [W] [M]
|
||||||
|
[L] [Q] [S] [C] [R]
|
||||||
|
[Q] [F] [F] [T] [N] [S]
|
||||||
|
[N] [V] [V] [H] [L] [J] [D]
|
||||||
|
[D] [D] [W] [P] [G] [R] [D] [F]
|
||||||
|
[T] [T] [M] [G] [G] [Q] [N] [W] [L]
|
||||||
|
[Z] [H] [F] [J] [D] [Z] [S] [H] [Q]
|
||||||
|
[B] [V] [B] [T] [W] [V] [Z] [Z] [M]
|
||||||
|
1 2 3 4 5 6 7 8 9
|
||||||
|
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 5 from 9 to 4
|
||||||
|
move 2 from 2 to 8
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 3 from 3 to 7
|
||||||
|
move 3 from 7 to 1
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 4 from 7 to 3
|
||||||
|
move 5 from 1 to 8
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 4 from 5 to 6
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 3 from 6 to 4
|
||||||
|
move 3 from 5 to 9
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 2 from 7 to 9
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 2 from 9 to 8
|
||||||
|
move 13 from 4 to 2
|
||||||
|
move 2 from 6 to 1
|
||||||
|
move 3 from 3 to 2
|
||||||
|
move 9 from 2 to 7
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 5 from 7 to 8
|
||||||
|
move 9 from 8 to 4
|
||||||
|
move 2 from 7 to 1
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 2 from 3 to 2
|
||||||
|
move 14 from 4 to 5
|
||||||
|
move 3 from 8 to 4
|
||||||
|
move 13 from 8 to 3
|
||||||
|
move 2 from 7 to 1
|
||||||
|
move 6 from 6 to 5
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 3 from 2 to 8
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 5 from 2 to 8
|
||||||
|
move 4 from 4 to 8
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 7 from 3 to 2
|
||||||
|
move 4 from 3 to 2
|
||||||
|
move 2 from 5 to 3
|
||||||
|
move 2 from 1 to 5
|
||||||
|
move 5 from 8 to 7
|
||||||
|
move 6 from 8 to 3
|
||||||
|
move 11 from 5 to 8
|
||||||
|
move 8 from 8 to 9
|
||||||
|
move 5 from 7 to 8
|
||||||
|
move 3 from 1 to 8
|
||||||
|
move 5 from 3 to 8
|
||||||
|
move 11 from 2 to 9
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 6 from 5 to 7
|
||||||
|
move 19 from 9 to 7
|
||||||
|
move 3 from 5 to 3
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 25 from 7 to 9
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 2 from 4 to 7
|
||||||
|
move 2 from 7 to 9
|
||||||
|
move 5 from 3 to 1
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 9 from 9 to 5
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 9 from 9 to 1
|
||||||
|
move 7 from 1 to 3
|
||||||
|
move 6 from 8 to 9
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 10 from 9 to 2
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 5 from 9 to 8
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 5 from 3 to 8
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 4 from 3 to 6
|
||||||
|
move 4 from 6 to 3
|
||||||
|
move 3 from 1 to 4
|
||||||
|
move 3 from 2 to 4
|
||||||
|
move 3 from 5 to 8
|
||||||
|
move 3 from 4 to 9
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 2 from 9 to 8
|
||||||
|
move 4 from 2 to 5
|
||||||
|
move 1 from 3 to 4
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 5 from 5 to 6
|
||||||
|
move 7 from 8 to 5
|
||||||
|
move 3 from 1 to 7
|
||||||
|
move 6 from 5 to 8
|
||||||
|
move 5 from 4 to 5
|
||||||
|
move 3 from 3 to 2
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 19 from 8 to 1
|
||||||
|
move 3 from 7 to 3
|
||||||
|
move 4 from 2 to 9
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 7 from 6 to 4
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 2 from 1 to 3
|
||||||
|
move 5 from 4 to 1
|
||||||
|
move 1 from 6 to 2
|
||||||
|
move 3 from 3 to 6
|
||||||
|
move 12 from 1 to 2
|
||||||
|
move 2 from 8 to 1
|
||||||
|
move 14 from 2 to 4
|
||||||
|
move 7 from 1 to 5
|
||||||
|
move 10 from 4 to 6
|
||||||
|
move 3 from 6 to 4
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 4 from 3 to 5
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 17 from 5 to 3
|
||||||
|
move 7 from 4 to 1
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 4 from 6 to 3
|
||||||
|
move 5 from 4 to 8
|
||||||
|
move 12 from 3 to 1
|
||||||
|
move 6 from 3 to 5
|
||||||
|
move 17 from 1 to 5
|
||||||
|
move 2 from 1 to 9
|
||||||
|
move 3 from 1 to 4
|
||||||
|
move 7 from 8 to 2
|
||||||
|
move 4 from 3 to 7
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 17 from 5 to 2
|
||||||
|
move 11 from 2 to 8
|
||||||
|
move 11 from 8 to 4
|
||||||
|
move 11 from 2 to 4
|
||||||
|
move 4 from 6 to 1
|
||||||
|
move 4 from 1 to 3
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 3 from 7 to 8
|
||||||
|
move 3 from 5 to 3
|
||||||
|
move 23 from 4 to 3
|
||||||
|
move 4 from 4 to 8
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 2 from 2 to 3
|
||||||
|
move 6 from 3 to 2
|
||||||
|
move 16 from 3 to 9
|
||||||
|
move 2 from 5 to 8
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 9 from 9 to 1
|
||||||
|
move 6 from 3 to 8
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 18 from 8 to 9
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 5 from 1 to 4
|
||||||
|
move 5 from 1 to 8
|
||||||
|
move 3 from 4 to 1
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 2 from 4 to 8
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 2 from 8 to 1
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 3 from 1 to 6
|
||||||
|
move 3 from 9 to 6
|
||||||
|
move 31 from 9 to 7
|
||||||
|
move 26 from 7 to 8
|
||||||
|
move 3 from 1 to 6
|
||||||
|
move 22 from 8 to 4
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 4 from 6 to 5
|
||||||
|
move 11 from 4 to 3
|
||||||
|
move 9 from 4 to 6
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 4 from 7 to 1
|
||||||
|
move 2 from 6 to 1
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 6 from 8 to 6
|
||||||
|
move 8 from 6 to 2
|
||||||
|
move 1 from 1 to 6
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 5 from 7 to 2
|
||||||
|
move 2 from 9 to 6
|
||||||
|
move 4 from 8 to 6
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 12 from 3 to 4
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 3 from 6 to 8
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 6 from 2 to 6
|
||||||
|
move 2 from 3 to 2
|
||||||
|
move 10 from 2 to 7
|
||||||
|
move 2 from 1 to 9
|
||||||
|
move 2 from 1 to 6
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 9 from 7 to 9
|
||||||
|
move 3 from 8 to 7
|
||||||
|
move 7 from 4 to 8
|
||||||
|
move 2 from 7 to 4
|
||||||
|
move 4 from 8 to 1
|
||||||
|
move 5 from 8 to 2
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 3 from 3 to 7
|
||||||
|
move 4 from 2 to 6
|
||||||
|
move 8 from 4 to 2
|
||||||
|
move 5 from 2 to 5
|
||||||
|
move 11 from 9 to 7
|
||||||
|
move 2 from 5 to 7
|
||||||
|
move 16 from 7 to 8
|
||||||
|
move 5 from 8 to 7
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 3 from 5 to 1
|
||||||
|
move 11 from 6 to 5
|
||||||
|
move 7 from 5 to 4
|
||||||
|
move 5 from 7 to 4
|
||||||
|
move 1 from 3 to 7
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 10 from 4 to 8
|
||||||
|
move 14 from 6 to 3
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 2 from 1 to 3
|
||||||
|
move 2 from 5 to 3
|
||||||
|
move 2 from 7 to 6
|
||||||
|
move 2 from 1 to 4
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 19 from 3 to 6
|
||||||
|
move 3 from 9 to 2
|
||||||
|
move 4 from 2 to 6
|
||||||
|
move 6 from 6 to 7
|
||||||
|
move 13 from 6 to 2
|
||||||
|
move 14 from 8 to 1
|
||||||
|
move 6 from 4 to 3
|
||||||
|
move 5 from 7 to 8
|
||||||
|
move 3 from 6 to 3
|
||||||
|
move 2 from 8 to 2
|
||||||
|
move 2 from 6 to 8
|
||||||
|
move 4 from 1 to 8
|
||||||
|
move 13 from 8 to 4
|
||||||
|
move 10 from 4 to 7
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 3 from 6 to 5
|
||||||
|
move 3 from 8 to 9
|
||||||
|
move 9 from 3 to 1
|
||||||
|
move 3 from 5 to 8
|
||||||
|
move 3 from 9 to 6
|
||||||
|
move 3 from 8 to 7
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 9 from 2 to 8
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 14 from 7 to 1
|
||||||
|
move 31 from 1 to 5
|
||||||
|
move 3 from 1 to 7
|
||||||
|
move 4 from 6 to 8
|
||||||
|
move 24 from 5 to 3
|
||||||
|
move 2 from 8 to 1
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 3 from 7 to 6
|
||||||
|
move 6 from 8 to 6
|
||||||
|
move 2 from 4 to 2
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 2 from 2 to 7
|
||||||
|
move 6 from 6 to 7
|
||||||
|
move 4 from 8 to 6
|
||||||
|
move 7 from 6 to 2
|
||||||
|
move 12 from 7 to 5
|
||||||
|
move 4 from 2 to 8
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 3 from 3 to 8
|
||||||
|
move 17 from 3 to 5
|
||||||
|
move 4 from 3 to 6
|
||||||
|
move 35 from 5 to 3
|
||||||
|
move 2 from 2 to 6
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 9 from 3 to 7
|
||||||
|
move 6 from 8 to 1
|
||||||
|
move 4 from 2 to 6
|
||||||
|
move 4 from 6 to 9
|
||||||
|
move 20 from 3 to 9
|
||||||
|
move 22 from 9 to 7
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 29 from 7 to 5
|
||||||
|
move 4 from 6 to 8
|
||||||
|
move 6 from 1 to 8
|
||||||
|
move 2 from 7 to 3
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 2 from 3 to 9
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 4 from 5 to 6
|
||||||
|
move 18 from 5 to 1
|
||||||
|
move 7 from 3 to 1
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 3 from 5 to 1
|
||||||
|
move 1 from 3 to 9
|
||||||
|
move 4 from 5 to 2
|
||||||
|
move 10 from 8 to 7
|
||||||
|
move 2 from 9 to 3
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 21 from 1 to 9
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 15 from 9 to 3
|
||||||
|
move 4 from 7 to 1
|
||||||
|
move 2 from 6 to 1
|
||||||
|
move 7 from 9 to 1
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 6 from 3 to 9
|
||||||
|
move 3 from 6 to 5
|
||||||
|
move 19 from 1 to 6
|
||||||
|
move 8 from 3 to 6
|
||||||
|
move 1 from 3 to 7
|
||||||
|
move 20 from 6 to 7
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 6 from 9 to 8
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 2 from 7 to 3
|
||||||
|
move 2 from 9 to 7
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 4 from 8 to 9
|
||||||
|
move 4 from 7 to 1
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 2 from 8 to 9
|
||||||
|
move 6 from 6 to 2
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 4 from 2 to 9
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 5 from 6 to 1
|
||||||
|
move 1 from 4 to 2
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 4 from 6 to 3
|
||||||
|
move 7 from 9 to 7
|
||||||
|
move 8 from 7 to 2
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 5 from 2 to 9
|
||||||
|
move 3 from 2 to 5
|
||||||
|
move 6 from 1 to 3
|
||||||
|
move 17 from 7 to 6
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 5 from 9 to 4
|
||||||
|
move 4 from 3 to 8
|
||||||
|
move 3 from 4 to 1
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 4 from 2 to 1
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 3 from 3 to 2
|
||||||
|
move 10 from 7 to 6
|
||||||
|
move 3 from 4 to 1
|
||||||
|
move 5 from 3 to 2
|
||||||
|
move 4 from 1 to 5
|
||||||
|
move 3 from 8 to 6
|
||||||
|
move 12 from 6 to 4
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 3 from 1 to 6
|
||||||
|
move 12 from 6 to 8
|
||||||
|
move 3 from 1 to 5
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 5 from 8 to 7
|
||||||
|
move 7 from 5 to 3
|
||||||
|
move 3 from 7 to 9
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 5 from 3 to 7
|
||||||
|
move 10 from 6 to 5
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 8 from 2 to 9
|
||||||
|
move 5 from 3 to 9
|
||||||
|
move 9 from 5 to 1
|
||||||
|
move 5 from 7 to 4
|
||||||
|
move 15 from 9 to 5
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 6 from 4 to 1
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 18 from 5 to 8
|
||||||
|
move 18 from 8 to 3
|
||||||
|
move 16 from 3 to 4
|
||||||
|
move 3 from 5 to 8
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 3 from 1 to 7
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 3 from 7 to 9
|
||||||
|
move 2 from 3 to 4
|
||||||
|
move 3 from 9 to 8
|
||||||
|
move 11 from 1 to 6
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 3 from 6 to 9
|
||||||
|
move 8 from 6 to 4
|
||||||
|
move 26 from 4 to 7
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 3 from 9 to 3
|
||||||
|
move 21 from 7 to 6
|
||||||
|
move 4 from 2 to 4
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 5 from 7 to 6
|
||||||
|
move 8 from 8 to 1
|
||||||
|
move 1 from 3 to 7
|
||||||
|
move 9 from 1 to 4
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 20 from 4 to 7
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 2 from 4 to 8
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 3 from 8 to 9
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 4 from 7 to 8
|
||||||
|
move 3 from 7 to 5
|
||||||
|
move 1 from 1 to 7
|
||||||
|
move 4 from 8 to 3
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 28 from 6 to 4
|
||||||
|
move 1 from 6 to 1
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 2 from 1 to 9
|
||||||
|
move 3 from 9 to 3
|
||||||
|
move 12 from 7 to 5
|
||||||
|
move 7 from 3 to 1
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 26 from 4 to 9
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 7 to 8
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 3 from 1 to 3
|
||||||
|
move 5 from 4 to 3
|
||||||
|
move 28 from 9 to 4
|
||||||
|
move 2 from 1 to 5
|
||||||
|
move 22 from 4 to 1
|
||||||
|
move 3 from 5 to 3
|
||||||
|
move 5 from 5 to 7
|
||||||
|
move 10 from 1 to 6
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 3 from 5 to 3
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 3 from 9 to 7
|
||||||
|
move 2 from 4 to 5
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 4 from 3 to 8
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 9 from 6 to 5
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 3 from 5 to 1
|
||||||
|
move 13 from 1 to 3
|
||||||
|
move 7 from 7 to 5
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 1 from 7 to 2
|
||||||
|
move 3 from 4 to 3
|
||||||
|
move 19 from 3 to 8
|
||||||
|
move 5 from 3 to 7
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 19 from 8 to 6
|
||||||
|
move 5 from 1 to 4
|
||||||
|
move 5 from 5 to 2
|
||||||
|
move 2 from 2 to 7
|
||||||
|
move 3 from 4 to 1
|
||||||
|
move 6 from 5 to 7
|
||||||
|
move 2 from 8 to 7
|
||||||
|
move 2 from 2 to 7
|
||||||
|
move 3 from 3 to 5
|
||||||
|
move 5 from 7 to 6
|
||||||
|
move 6 from 6 to 1
|
||||||
|
move 2 from 5 to 1
|
||||||
|
move 2 from 4 to 3
|
||||||
|
move 1 from 5 to 8
|
10
2022/day5/rust/Cargo.toml
Normal file
10
2022/day5/rust/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "rust_2022_05"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aoc = { path = "../../../common/rust" }
|
||||||
|
regex = "1.7.0"
|
109
2022/day5/rust/src/main.rs
Normal file
109
2022/day5/rust/src/main.rs
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#![warn(clippy::pedantic)]
|
||||||
|
|
||||||
|
use std::io::{stdin, Read};
|
||||||
|
|
||||||
|
use regex::Regex;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut data = String::new();
|
||||||
|
stdin().read_to_string(&mut data).unwrap();
|
||||||
|
|
||||||
|
let mut lines = data.lines();
|
||||||
|
|
||||||
|
let mut stacks = Vec::new();
|
||||||
|
|
||||||
|
for line in &mut lines {
|
||||||
|
if !line.contains('[') {
|
||||||
|
lines.next();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i, crate_) in line.as_bytes().chunks(4).enumerate() {
|
||||||
|
if stacks.len() <= i {
|
||||||
|
stacks.push(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if crate_.iter().all(|&c| c == b' ') {
|
||||||
|
// empty space
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let crate_ = crate_.strip_suffix(b" ").unwrap_or(crate_);
|
||||||
|
|
||||||
|
let Some([crate_]) = crate_
|
||||||
|
.strip_prefix(b"[")
|
||||||
|
.and_then(|crate_| crate_.strip_suffix(b"]"))
|
||||||
|
else {
|
||||||
|
panic!("invalid crate {:?} {}", crate_, std::str::from_utf8(crate_).unwrap());
|
||||||
|
};
|
||||||
|
|
||||||
|
stacks[i].push(*crate_ as char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for stack in &mut stacks {
|
||||||
|
stack.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
let stacks = stacks;
|
||||||
|
let mut stacks_9000 = stacks.clone();
|
||||||
|
let mut stacks_9001 = stacks;
|
||||||
|
|
||||||
|
let regex = Regex::new(r"move (\d+) from (\d+) to (\d+)").unwrap();
|
||||||
|
for line in lines {
|
||||||
|
let matches = regex.captures(line).unwrap();
|
||||||
|
|
||||||
|
let amount: usize = matches[1].parse().unwrap();
|
||||||
|
let source: usize = matches[2].parse().unwrap();
|
||||||
|
let dest: usize = matches[3].parse().unwrap();
|
||||||
|
|
||||||
|
let source = source - 1;
|
||||||
|
let dest = dest - 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
let (p1, p2) = stacks_9000.split_at_mut(usize::max(source, dest));
|
||||||
|
|
||||||
|
let (source, dest) = if source < dest {
|
||||||
|
(&mut p1[source], &mut p2[0])
|
||||||
|
} else {
|
||||||
|
(&mut p2[0], &mut p1[dest])
|
||||||
|
};
|
||||||
|
|
||||||
|
let sourceidx = source.len() - amount;
|
||||||
|
|
||||||
|
dest.extend(source[sourceidx..].iter().copied().rev());
|
||||||
|
source.truncate(sourceidx);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let (p1, p2) = stacks_9001.split_at_mut(usize::max(source, dest));
|
||||||
|
|
||||||
|
let (source, dest) = if source < dest {
|
||||||
|
(&mut p1[source], &mut p2[0])
|
||||||
|
} else {
|
||||||
|
(&mut p2[0], &mut p1[dest])
|
||||||
|
};
|
||||||
|
|
||||||
|
let sourceidx = source.len() - amount;
|
||||||
|
|
||||||
|
dest.extend(source[sourceidx..].iter().copied());
|
||||||
|
source.truncate(sourceidx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
stacks_9000
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.last().unwrap())
|
||||||
|
.collect::<String>()
|
||||||
|
);
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
stacks_9001
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.last().unwrap())
|
||||||
|
.collect::<String>()
|
||||||
|
);
|
||||||
|
}
|
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -2,6 +2,15 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "0.7.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc"
|
name = "aoc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -392,6 +401,8 @@ version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
|
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -484,6 +495,14 @@ dependencies = [
|
||||||
"aoc",
|
"aoc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust_2022_05"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"aoc",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.11"
|
version = "1.0.11"
|
||||||
|
|
|
@ -14,4 +14,5 @@ members = [
|
||||||
"2022/day2/rust",
|
"2022/day2/rust",
|
||||||
"2022/day3/rust",
|
"2022/day3/rust",
|
||||||
"2022/day4/rust",
|
"2022/day4/rust",
|
||||||
|
"2022/day5/rust",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue