aoc-2021-rust

git clone https://git.sinitax.com/sinitax/aoc-2021-rust
Log | Files | Refs | README | sfeed.txt

commit 1ec4495528dc560999b7840fa6c6d6dac059102b
parent 05438ad725ffc0c53dd69740d92c153d8cb3ca6b
Author: Louis Burda <quent.burda@gmail.com>
Date:   Thu, 20 Apr 2023 02:20:04 +0200

Add day 25 solution

Diffstat:
Asrc/25/Cargo.toml | 7+++++++
Asrc/25/input | 138+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/25/part1 | 307+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/25/src/main.rs | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/25/test1 | 10++++++++++
5 files changed, 562 insertions(+), 0 deletions(-)

diff --git a/src/25/Cargo.toml b/src/25/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "day25" +version = "0.1.0" +edition = "2021" + +[dependencies] +aoc = { path = "../common/aoc" } diff --git a/src/25/input b/src/25/input @@ -0,0 +1,138 @@ +>.>..v..v.>vvvvv..>>>.>vv>vv>.......vv.vvv..v..vv.>v...>>>>>>.v>.>..>v.>.>v..v.vv.>.>...v.v>....v..v.v>.....v....>.>..v>v>.........>.v..... +.>>.v..>..>vv>vv..vv>....vv>.>.>.>v>>......>>v..vv>.>>>..>>.>v.v.>v>..........>>....v.v....>>>>>.vv.v.v>v.v>...>>.>vv.v..>v>.v>..v>..>>...> +vv...>.>...>.>.v..>...>....>vv.vv.>..v.>>.>v...>.>>.v>v.v>..>....>.vv..>v..v>.>.>.>.>.v>.v>.....>vv..>...>>...>.vvv>.v......>v....v.>>.>.>. +v>v>...>.>>.v>v.v....vv>..v.v..............v.>v..>..>..v.vvv...>...vv>.>v.>>>v.>>.v>>>>..v..v..>...>v..>vvv...>..>...v>v.v.vv..v.>.>vv.>>.. +vv...>.v...v..v>.v..v....>...vv..>v>.>.>>>...>vv.vv...vv>>..>..>.>..........v..v.v.>.>...>.>v.v>.v..>vv....v.....>.v>..>>>>v.....>......v.. +v>>..>>>v...>.>>...>>vv>...vvv>.v>..vv.>>..v.>vv.v..>>v>vvv.v.>v..>v>vvv..vv.>>v..v..v.....v.>.>>>vv.>...>>>>>..>vv>>>.v....vv...v.>.>vv... +>v..>>v..>..>....>.>.v.>..>...v..>.>.>.>...v.>v>>>.vv>vvv.>>.v>.>v>.vv......v>.vv..>...v>>.v>...vv.v>.v>.>>..v>.v.v...>>>>>.v.v>.v.v....>.. +.>>>.>..v>>>>>>>vv.v>>...>>>v..vvv>.....>.......>.v>.>>>..v.>>>.v.v>.>>....v.>.>>.v.v>v.v.v>>v>v.v.v.v>>>>v.v....v..v>...>.v.>.......vvv>.> +..v......v>v.>vvv.v.......>.....v>.....vvv..>...>v....>..>>..>.v.>..v.>>>...>vvv..vv>.>v>.vvv>.>......>>v.v>>v.v..v>vv.>v.>..>>v>>.v.vv.v.v +>v...>.>..vv..vv.v.v>>..>>..v..v..>.>...>.vv..vv.>..>..v.v.vv.....v.....v>..>>>.v..v>vv>v..>...vv>>>.v.>>.v>....vv..vvvv..v>v.>>...v.>v.>.v +.>..v.>v.>....>>.v>..>>.v..v....v..v..>v..v>>>v.v>...>..v>.>.>>>.>..v>...v.>.>..vvv..v>v>.vv.>v.v...>...vv..v>v.>>v>.>>.>>..vv>.v.v>v.>.v.. +.v>>.>..>.>>..>..>.v.v.v>.>v...>.........v>>....>.vv>>v.>v>.............>.>v>v.v..>v...>.>v...v..v..v.v>>....v.>>.>v>..v>>.vv..v.v...v>..>. +>v..vv..>..v.>>.vvv.v.>>>>vv.>v.>v.....>...v...>.v.......v>v.>vv...>v..vv.>.vv.>.v>>v>>v.v>.>....>.>>>>.........vv.>..v..>v.v.vv.v..>>v...> +v.>.>>....>..>.>.v....vv.>>v>>...>..v..>>>>.v.>v>>..v>......v>v>>..v.v>..v.>>v..>.v>v.v.vvv>.>v.....v.>.>..v..>>.>..>.>v>..>.vv>v>>..>>v>>. +v..>>.vv...>.v.>vvv>>>>.>vvv.v......>vv.>.>..v..v.v>>.>>>..vv..v>>..v>vvv>..>>.>v>v..>.v.>vv.v....>.......vv.v...v.v.v>>v.vv.>.>..>.>..v.v> +vv>.v>...>.>>....>v.>..vv>..v.>.>>.v.v>...>>...v..v.vv>.vv....>...v>.vv.vv.v.>v.vv.v>>v.>>vv.v.>...vv.>v.......>>.>.vv>.>v>>.v>.v.>..vv.>.> +.>....>...>v>.>>>..>vv...v>...v>...v>.>v>......>.>v>..v>.>..>v...>...v..>.vv..vvvv>...v.>v.v....vv..>.v..v.vv...>vv..>.v.vv.>>.v.v.>..v.... +vvv>>v......v....>.>v....>.>vv....>.>.>>vv>......v>.v..>.v..vv...v>vvv.v>.....vv..>vvvv.v.>...>.>v>>vv>..vv.....>.>v..>v...>v>..v.>..v..... +.v.>>..>>v>>>>>.v>.v>.>.v.>.vv....>.v..>v.v>>.v.v>vv..>....>....vv..v...v>vv>v>....>>.>.vv>.v>vv....v.v>..>>...vvv>v.......>.v>v.v..v...vv. +.>.vvv>.....>.>v.v..vv...v.v.vv.>...v...>vv..v.>..>v..>v..vv.v........v>>..>.v...v.>..vvv>vv>.>v.>>..>.>....>.v>>>v>..>v.>>.v...v..v....v.v +vv..vvv>.>v.v>>...>v.>.>>..vvv>>..>.v>>>>....v......vv>>>v.>...v..v>v..>>v..>>.v..v..v>>v.v..v.vv.vvvvv>.v.>....v..v.>.v.....>....>.....>.. +.>.v.vv...v>...>.v.v.v.>.>..>.>v..>v...v.>>..v...>>v>v>vv..>..>.v.>.>.>>.....>>v.>v>>...>..>.>>..>.v>...>v.....>.v.>>..vv.v.v...v>.>.>..... +.v>>vv>.v>.>vvvv....v>v>.v......v...>>>.>>.>..vvv..>....>>v>vv.>.>v>vv.>.v.v..v.v..>v>.v>v>.vv>v.>>v>...vv>.....>>v>v>v..v>..>.vv.>>.>...>. +v.v.>.v....v>.v.v..>v>v.v.v>.vv>.......>vv..>>.vv>>vv.>..v>>.>vv>v>>..v..>v>>>>vvv>>..v..v>v>>v>...>.v..>>...>.>.v.v.vv.>v...v.>>.>.>.>.>>> +>>>v.>.vv>.v.>.>v.>>.>..v>..>v>>..vv..>.>.v...v>.v.>...>>vvv>v>>>v>v>....>v..vv.>.v>...>.>>>.v>.v...v....>>v>v..>.>...>..>>>.v..>v..>v..>v> +.v...v...>...v>.>..vv.>....vv....v...>...>>v..>.vv.>v.>.>.>.v.v>.v.>vv>.v>v.>....>..>..>.v...v..>>..vvv.v.>v>..>vv..>.>...v...vv.vv>...v.v. +..v.....v>>vv.v>v>vv.>>..vvv.>v..v>.......>>>.>...>..v>v.>>..v.vvv..>.>>.>v.>v..>>.vvv..vv....v>...v.>>...>>....>>......>.>>...>.v.>....v.> +>.>......>..v>>vv>.v.v...v....v>..>.v>>>v....v..>>>>>....v......v>...>.>..>..>v.>>>>..>.v>>v>.....>.v.v.>..vv>>>.>v>..>.v>>>vvv..>...v..... +v..>v>vv>.v>>.>>v>.v..>.>.v..v>>>>..>vv.v.v>vvvv>.>..v.vv>v...>v>>.v..>..>v.v.....>..vvv>.v...>.vv..>>>>>.v.v.vv.v>..v..>..>v.vv.>.v..>.v.> +>..v...v>>>.>vvvv>..v.>....>vvvvv.>v.v>v>.>.>v>>>.v..>.vvv.>>..>v...>.v..>v>.v>vvv.>..>.v>v...>v>.v>...>.....>v>...v......v>.v.>>>...>.vv.. +>...v.>v.v.>>.>..>.>vv.vv...>>v.>v.vv.>v.>..>.v>..v..v.v..v.........>>vvv.>...>vv.v.>vv>v>v.>>>vv>vv.>..>...>>.>.>>..>....>v.v..v..>...v.>> +>v.>.....v....>.....>..v>v.>.v>>v>...>vv.>v.>v..v...v>v.v.>..>v>....vvvv..>.>.vv.>.>v.>v.v....v.v....>>.>..>.>>....v.>vv..vv..v......v>.>.> +>.vv.v>v....vv>>.>v..>...>..>.>>...>>...v.>v>.....>..v..v.v..v>...v>vv..>.v>.v.v.....vvv..v>vv>.>>vv..>>v.>>.>.v.v..>.>>v.v.v>......>...>v. +.v.>....>v..>>>..>...>v>>..>>..>.>v>.v.....v....v.v.>...>>>....v......vv.v.......v>.>>.v..>.>>.vv>v....>v.>....>...vvvv..>v>.v.v..>v.>v.>.. +v>..v>>..>>>.>>>v..>.>.>>.>>....v.v..v.v.v...v>.>..v>..v>>v.>.>.>vv.....>>>..>>.......>.>.v.v..>.>...>v.vv.vvv....v>>vv>>v.>.vvv.>>vv...>vv +>..>>>v>v..vvv>.v.>>..v.vv>..v.vv>>v......vv.v.>v>>v>.....>>.>>.>....v.vv>.>v......>>v.>>.v.>..v....>..v>.>v.>...v...........>..>v..v.>v.>> +.v.>..v...v>...vv.>..>>.>>v...v...>..vv.....v......v..............>.v......>.>>v.>...>v..>v>...v.vv>..>v>>.>.v...>.v>vv..vv.>vv>..>.......> +.vv...v..vvvv.>...>.......vv>.vv.>v.>.v..v>v..>>v..v.v..vv>>..>.vv..>>.>..>..v......>..v.v>vv>v..v.vv>vv.....>.....>v.v>>.........v>..vv>.> +v.>..>vv>..>>v..v>.v.vv..>>...v....v..>>.v..v>v..>>.v...>.>>.>..v.>..>v>.>v.>v.v>..>v>>....v.>>v...v...>vvv....v>...>....v...>v>>.vvv.....> +>>>>>>>.>>.v..v>..>.>.v.vv.>vvv......>v......>v>v.v.vv.v>.v.>........>v>.v...>....vvvv.>v..v...v......v>.v...>..>.>..>..>.v..>>..vv.v..>..> +>..>.vv.v>.v..>.>v...>.>.v>vvv>.v...v...v>vvv.>....vvv>>.vv>......>.>..>.vv.v.v.v.v.v>v.........>v.>v>v..>>..vv.v>v.v.v.>>>v>...v>.>v.>v.>. +.>>.>>..v>..v....>>..v>>v..>..>v..v.v..v..>v..>...>v.v.>>>v..vv.>>.v>v...v.....v.>v>..v>.v>>v.>.>..>>v....>>>.>vv..>vv..vv..>v>.>.v.>>vvv.. +..v.v>>..>v..>.>.>....v>>.v.v.v.....>..>....>v>>.>....>.>v>>.....v>..vv.>v.>..>v.....vv.>>>...>>.....>.>v...........>>....>..v>....v..vv>v. +vv>...>>..vv..v.v..>>.v.>vvv.>.v>v>v.>>>>...>v.v>...>v>..v.>..v..v.>....v.>.>v>.>...v..>v..>v.v>..vv..>.>v.v>.v.v>.v.>>vv.>v>.v.v.>..>..v>. +...>>>...vv>v.v...>v.>>..v.>...v..vvv.v..v>vv>v.>v.>...v..>.>>.>v.>...v..v>.v>v>v>..>v.>.>>vvvv>>.v..vv......>.v.>>>v>.>.v>.v.>.vv..>>..... +>>>..>vv.v.vv...>.>v..v.>.>>.v>v>>>v.v........v.v.v...>..v>>v......v>>>.v>v..v>...>>>.vv.>v..>>.vv>>v.v........>..>>>v.>.>..v>v>.vv...v..>v +.v.>......>...>>.>.v..v>>v.>vv..vv.>..>>>....>.v.>....v.>..v......v.>>>.>v..v....vvvv.....v....>.v>>v...v..v>>..v>..>.>v>v..>.>....v>v.v>.. +.>.>.vv.vv.....v.>..v>.>v.v.v....v..>>vv.v..vv.>..v...vvvvvv>.vv......>v.v..v.>v>.v..>>vv>..v>v.>>.v...v.....>v>..>>.v.>..>.>..>v.v>.vv>... +........v.>....vv.>..>vv>...vv.>.....>..v.>>v..>vv>>v>.......v.>>v...>vv>...vv.>...vv..v>.v.>...v.>>>>>..v..v>>v.>...>.>>>v>...v>.v..>..>.. +>.v.>>.v......>...v.>>..>v...v.>.....>v....>>v>.>.>..v>>..v.v>.>..vvvv.v......>..v.v.>>.v..v....v.vvv.......vv>...v.v...v>v>>.>..v>.>>..... +.v>.>>v.v>>.>>.......>>.>...v>>.>>v..>...>..vv.v...>vv....vvv.vv..>.v.>vv>.v>.>>..>.>....v>..v.v..v>.>...vvv.>v...v...>.v...>>vv>...v..>>.. +..>.....v.>v.v..v.>v.>v>>..>v.v.vv..v.v..v..v..v>..>.v...>..>v>.v.v>.v>>vv.v.vv>vv>v>...>...>>v.v>.>>v.v>....v..vv..>>>>>.>.>..>v..>>...>>> +>>>.>.>.v.v>.>v>..v....v.v.v.v.>.vv>...v.>v.>..v..>.>...v.....v>v.>vvvvvvv...>>>..>.>..vv.v.>vv.>.v.>>>.v>>.>.v.>.vvv>v.>>.v.v.v.........vv +.>.v.vv.vv.>v...v.>..v>>>v...v..>..v.>v.v.>>.v...v.v.vv.v...v...v>.>..v...>.>.vv..vv..vvvv>.v.>>..>v>>>>v..vv.>..v.v.v.>>......>.v....vv.vv +>v....>vv>..vv..v..>.>..>v.vv.>....>>>...>>>.vvv>>v.v.v.>>.v>vvv>.>>.>..v.v>>>>....v>>.v>.v...>v....>>vvv.>v.....v.>v...v.>v..>>v..v..vv.v. +vv>.v.v>.>v..>.>>vv.v>..vvvvv.......v>..>.vv.>v.v..v..>v>>>v>vvvvv>v.vv.>>.v..v......v>....v..>...v>v.>vv.v>.>v.v..>>.v..>>>v...>..v.v...>. +v.>v..>....v.>>.>..vv..>v>v.>....>....>v.>.v.>>.v>..vv.>v.vvv.>.....>..>.>...>>>..vv>>v...>>..>vvv.>>..v>.vv...v...v..>>v..v>..>.v..vv....v +>v>.>v.>>..vv......vv..v...>...vv....>>....>.v..>vvv>..>.vv.vv>>v.>v>.>.v..v>v...v>>..>>>.>...vv..v.>>>...>.v.v>..vv.>v>......v..>v>.>..v.. +.v>.>...vv>vv.>v...>..>v.>v....>..>v>v.>.vv>..v.>v.>v.v>.vv.>>v.....>.vv..v....>vv.>.v.>>vv.v...>..>>v>.>v.>...v.v..>.>......vvvvv...v.v>.> +v..v>v...v>>v.v.>.>.>v.v>.>v>.vv.v.v.v..>vv..>.>v>.>v...>v>v.vv>>....>...>..vv.vv.vvvv.>....>>>v>.....>>vvvv.>.v...>vv..vv.>.>>.....>v..... +...>v....>.v>..>.v>..v>v..>...>.>..v....>>>..>..vv.>.v>..>>v...v.v...v..v..v>v>....>>...vv.>>..>v.vvv>.....>.>v.v....>v..>.>v......>.v>>v>. +v....vv.....>>v.vv.vv..>>...>v.>v>v...v>>..v>.v>>>v.v.....>>vv>..v..v>.vv>v>v>..vv..>>...v...>v>....v>..v>.>.>>...>>>....>v.>.>.>.vvvvv.>v> +v......>v..v...>>vv>>>.vvv.>>.vvv>..>..v>.>.>>..vv...v>v...>..>>....v........v...>>.v>...v..>.>>......>..>>...>v.v..>..>v.>>..>.>..v.v.>v.. +.>>>>vv>...>.v...v.vvvv.>>>>>...v>>.vv.>..v>.v>>vv.v..vv>...>.v...v..>.v..>..v..v..v.v>..>>>v.v.v.......>v..>.v>>>v...>....>>v>>v>>>v>>.v>. +..v..v.....v..v>>vv>>.>>v>>...>>....>>.>.v>........>.>.>>.>....v.>v>..v.>v.v.vv>..>..v.>.v...>.>v.>..vv..>vv.>>..v....>.>v..v>.>>>vv......> +>.v........v>..vv>.v..v.>>.vv>v>..>v.>v>.>v....vv.>..vv>>v..v.....v>..>v...>...>>vv.>>vv>>>v>.>.v...vv...vv...v..>v...v.>v.v>..>.v......>.. +>>>...vv.v.>.v>>>.v.v..>>>.vvv>....v>>....v...v.v>>..>>.>....v..v..v.>v..>..>...>.vv.>.v.v..>v>.v..>......>>>..>>.....>.v>>..v..v.>...v.v>. +.vv.v.>.v...>vvv>.....vv.vv>v>..v....v.>>.v..v>..>.v>.v.>..>>....>v.....>vvv.>v.....>.v>>..>>.>...v>>>.vv.v>v..>>.v>.v........>......v..>>> +v>..>>.v...v>.>.v>..vv.>....v..>...>v.>.>..v>.>.>>.v..vv..vvv...v..vv.v>.v>..>....>v.>vvv.>>.v.>vvv...v..v>>.v.v.....>.>.>...>v.>v.>.vvv>>> +.>>.v>.v..>...>.v.v...v>>.vvv..v>.>v.>>>>.v..>v..vv...>..>>>.>..>...>v>>v>..v....>>vvv..>.>....>.>v>.>.vv.v..>.v>>>>v>>v...v.>>>.v.vvv.>vvv +.....v..v..>.>.>..>>.>.v>vvv.v.....>.v.>v...>v>v....>>>>..>>...v.>.>.....>..v.v.v.>v>.>..>v..>v...vv.>.v...v>>vvv...vv.v......v>.>>..>v>... +>v..vv>.v..>v>..v.vv.>>.>>v....vv>..v>>v.>.v>.>>v...>..>..v>>..>vv.....v>>v..>v>>>.>.>>.v>v...>v...v...>..v.v.v>....>.>v.>.v...vv.v>>.vvv.v +...>v>.>.>>.vv..>.>..v.>>v>v..v>>...vv>.v.v...>..v>>..vv....>v.v..>v>.>.>>.......v...>v>.>.v...v...>>.>>v.vv>v..>...vv>..v>.v..>.v>vvv>vvv> +v.vv>..>>.....>>.>>v.vv>v.vv>...vvv...>..v>.v>.v>..>v.vv>.v.>..v.....>v..>v>.vv>.vv>>..>v..v...v>.v.v.v>>v.vv>..>.>v.>.vv>.>.>v>vv.>v.>>.>v +>>..v>.>..v......>v.v>....>.v.....>>.v.>.v...vv>>...v>.v>..v..v>..>v.vv>>v>..>.v..>.....v>....vvv>v>...>..v.v..>vv..vv..v.v.v...>>.>>>....v +v>...v>vvvv..vvvv.v....>v>...>v>>vv..>v.v.>>.>..>.v.>vv.>..v>>>.v>vv>>.>.v.........>.....>.....v.v>.>v.......>..v>..>..v.v.>v.>v.>vv.>v...> +.v..vvv>.vvv>>...>..vvv...>>.....v>v..vv.>v...........v...v>.>.vvvv.....>vv..>v.v.>..v>v.>v.>>.>.v.>.>v>.>v.>>...>vv>v..>>v....v.>.>vv.>vv> +.v>.v.....>vv.v..>.>v..>>..v.vv.>v.v>.vv>..vv.>....v...>..>..v>.>>...>>>....v..>..v..vv.>>>>>v.>..>.....vv>.....>v>.>..>>..vv.>..>..>v>.v.. +>.>.>>>>..>.v.>.>.>..v.>.>>>..vv>.>vv..>.......>>v.v>.>.v>v.v.>.>.....v..>v..v.v.v.v>v........>v.>vv.v.v>>.v>..v>.v...vv...v.vv.vvv..v..... +.v>.>....v.v..v..v...>>v>.......>.v>>v.vv.>.>..>.v>.>v..>>vvv.v.......>v...v..v>...v>>.v>v>>vvv....v...>.v>..v.v....v>.>>...>..v....vv.v>>v +...>>v.v.>v.>..>>...v>vvvv.>..>...>vv>.>..>v.v.v.>>....>>.v.>...>>>>.vv.>.vvv>v...vv.v>v>>v....v>.>..v..>>..v.........>v>.>>.v>>>.vv..v.... +.v......v.v.v>>..v..>>.>v>>v>>..v>v.v>..v>...>>.>>..>v..vvvv..>......v....v.v..>>.v>v.>.>.v.vvvv>.....>v>.>..v>>..>...>vv..vvv>vv.........v +...>.vv..v.v..v..>>..vvv...>v..v..>>>..v..v.>..>..>v...>......>v.>>v...>v.>>>.>.v..v.v..>>.v.>>..v...vvv....>v>>..v..v>v.>...>.v.vv>v>..v.. +>..>.>.vv.>.>.v..v..v.>v...>.>v....>>v.vvvvv>>v...>vv.v....>v...vv....v.v.......>..v.>.v.>..v..v..>>v.>>>v..v>.>vv...>...>v.>>.v.>vv..>>..> +..>.>.v>.v.v>v.>.>>.v...>....>>v>vv.vv>v..>v>>...>vvv.>.v..>>>>..v.>>.vv..>>..>v>..v>v..>>v>.vv.v.vv.....vv.v..>.>.v.v>>....v..>....v>v>>v. +..>.>.v.vvv..v.>>.>.>.>...>.>..>.>>..v>..>v.v.....>.vv...vv..>>>..v>>.v.>..>..v>..>...v>>vv...v..v..v>>.v.v.v>v.>.>>..>.>..>......v........ +>....>...v..v..>...>vv>v.vv.>vv.v>.v.>.v....v.>......vv.>vv>.>v....>.v>.vv>>.>..>v...v.v....>>...>v.vv.v.....>v...v......>.>.>....>...>v>v> +..>vv...vv.>.>..v>.>.>>>..v.v>v>>.>vv.>.v.v.>..>>....vv.....>vv.vvv.>>>vv.vv..v>.>.>..v>.v.>>...>>v..>v.>>.v......vv>>.>>v.>.>.>>.>.v...>.> +>..v>>.v>..v.v.>.vv.>...v....>...>..vvvvvv........v.vv>>.....v>.v...>.>>...vv..>...>>....v>.....>>.v....>v.v...v..v..>.vvv.>v...v.v>v.>...> +.>.vv.>..>>..>.v>..vv.vv.v>v.>.v.>....>..vv.>.>..>v..>..v.>>v..>vvv.>.>vvvvv..>.>...>>.v..v>v....>...>..>v.>...v....v>>v.v.v.v>v>.v.>.>...> +>.>>v..>..>....>v>.v.v>.v.>.>..v>v.>v>>>.>>..v...>.v.vv>.>.....>.v.>...v.v.v>>>.v..>>v>...v>.>v....v.>>.vv>....>v>.vv...>v.>..v>v>v.>..v... +v.v..>>v..v>>.vv>.>.v.>v...v....v.vv>..vv...>..v>..vvvv..v.v>v.vv....>.>.>....v>>..>vv.>..>v.>.>..>...v.>.>v>.v.>v>>>>>>v.v>.>v>.v...>..>.. +>>..vv.>...v>.>.v.>v.>..vv>>vv>.v>v>...vv...v>.>.>>v...v>>vv.v.vv.....v....v>v........>v>v..>v.>>v...v>>..v..v.>>....v>....>vv>.v.>vv.>.v.. +>..>>...>.v.vv>v..v>>>>.>v.vv....v...>v..>>vv>v...>..v.>v>>..v>.>>>.>....vv..v..vvv>v.....v.>.>v..vvv....>..vv....>>v..v.v...v.....>>v..... +...>.>..v>vv>....vv>v.v>>>..vv...>......>.....>..>...vv>..v>.>v>>.v..>>..vv>v.v..>.>.v..v.>v>>.v...v.v>v..v>v>v.>.v>v..v.v...>.>v>..>.....> +v.v>.v.>.....>..>v....vvvv>>v>v>.>v.>vv.>.v....>v..v.v....v>vv..>...v....v..v....v>v>.>..>.v>.vv.v.vv..v>.v>.>v.>.>..>..>v......v..>v.v..vv +v>.v>....>...>v..>v>..vv>....>v>v..>v...v..v>>...v>>...>v>..v.>v.v......vvv>.v.v.....v......v>v.>...v>.>.>.>>.v.>>>.v>...v..vvv>>....>v...> +vv..v>v>..v...v.>>>vv..v...>.v...>..v..v.v>..>.vvv..>v..v.vv>v..>...>vvv>v>...>v>..v>..v>.v>>..>>..v>v.v.>v.v>....>..>v..>.v..v>>>v..>>.>v. +v...>v>.>>vv>.vv....>.>>v.v>>v.v..v>>.vvv....>.>>.v>>........v.>v....v....v>.>.>v..>v....v>>v...>.>.>v.v.v.v.>...>>..v..>v.v>...vv.v>v...>v +.>...>vv..>v..>.vv>.>.>v.>vv>v..>v.>..v>>vvvv.v>...v..>.>v.v.vv....>v...v............>vv.>.v>..>v...>>..v>.>.>...>.v.vv.v.>...>.>.>>v..vv.. +..>.>...>vvv>.....>>vv.>>v.>.>...vv>v.>.v...>.>.....>>..v....>..>..vvv.>vvvvv...>...>..v>v>vvv...>v>.....vvv.>>>.>.......>.......>v..v.v>.. +v...>>vv..>>..vv..v>.>.......>.vv.>>>>..>.>v..>...>.v.vv..v.v.....v>v...>>.>..>....>>..>.v..v.>vv..v>..vv>.>.v>v.>..v.>.v.vv.>...>..>v.v>vv +.v..vv>...vv.v>.vv.v.v...>v>.vvv..>>.>>v>>.>.vvvv.>...v>>>vv.>v>..>.>...>.v>.vv.v.>...v.......v.>.>v.v.v.>vv>...v.>.>...v..v>vv.>>.......>. +>.>.....v.>>v.>v.>.>v.v>v>..>.>>v..v..v.v..>.....>.v>v.v.v>vv..v........>.>v...v>v..vv>v.vv.>vv.>v..v..>vv...>...vv.>.>.v>.>.vv.v>..v.vv.v. +...>v>.>>.>..vv...v.v.v..v..vv...>.v......v>.>>vv..v.>.>>>....v.v..vv.vv....>v>.>>.vv.v>.v.>....v.>>.vvv>v....v>v>.>v>.v.>vv.vv.>v>>>.>>..v +.v..v.v>.>vv.vv.>>.v>v>v.>....>>.vv..v.>.vv.>...>>......v.>v>.v...v.>>v.v>vvvv>vvv.vv>..v>...v>>.vv.vvv>.>.v.v.>>vv>>>>v...vv>.v>v>v...>vv> +.v>vv>>...>>....vvv>.......vvvv..>>>v>v..v......>..vvv.v>vv.>...>..>.v......>....v>.>v...v>>.vv>..v....>vv.>...>>.>>>.>vvv>>>>.v.>.v..>.v.v +>.v>..v..v>..>....>>>v.vv>...>.>>>v.>v>.vv...v.>v...vv..>>>>.>>..v....v.......>.>.v.>.>v>>>..>....vv..>..>>.>v>.>..>v.>>v....v..>>>v.>vv>.. +vv.v..v>>....v.>v>>.>>.>..>.v>v..>v..>vv......v>.v.v..>>.v>.v>vv>.>..>...>>.vvv>...v.v.....v.>vvv>.>.v>.>>.v.v.>v...>...>.....v.>>>>vv..v.. +v.>>.>...>..>>.>>vv>>>...>v>v>>vv..v....>...vv.....>vv>.>>.v....vv>.>.>...>v..>.vv.vv.vv....>v>.>..v>....v>.>.vv.>.>>...>.v..v.>>v>>...vv.. +v....>..>>..>>>>v.>..>vv..v>>....v>vv.v..>v.>v.v.>...>v....>v.>>>v>.>..>v.>>...v>>..vv.>vv>v>..>>v.>.v.>v........>v.v>.........>>..>>.v>v.> +vv..v.>>>v>....vv..vv.v>>v.v...vvv>...vv>.>...>>>vv>>...>v.v>..>v....v.>v.v..v.>v>>>>.>v.v.vv.>>..v.....v...v>...>vv>.>vvvv>>.v..>.v..>v... +>...v..vv.....v..>.>>...v..>..v.vv>>>>..>.>.>v.v>v...>v>>v.>>..>.vv.v.>>vv..vv.>>>.>v.>v.>>...>>>.>.>>.>...v>v...v>.>>.>>.v.vv.>.>>>.>>vvvv +.vvv>.>v.>.....v>>.>.vvv.v.v..vv.v>.....vvv.vv........vv...>...>.v.v.>.....v.>.....v.>.v>>.v.....>v.v>.>...v>..>>.v.v.v.>..v>>>>.>...v>vv.v +>>>>...>v..>vv>.>v...v..v>>v...v.v..v...>.>>..v>v.v.vv>.>v....v...v.v>.v>>v..v.v>v>...>vv>..>vv>>..vv>..>.>.>..>.v.>>>..>...v>..>.>.v.v>vvv +>v>.>.>.v..vv.>v.vv>..v..v.....v>.>>>>..>v...v.>vvv.>.>>>.>>>.....v>.v..v.>.vv.v>..v..>vvvv..>vv.v>>>v.v>..v.v..v..>....>>>.>...v..>..v..>. +.>..v>v>.v.vvv....>..v>..v...>.vv.>v..>.v.v>>..>>.v.v.v.>...>.>..v>v>.......>>.>>.>v...>>v>.v..>.>>>....v>>..v.>.>v...v>v>>v.>.v>...>.v>... +..>>>v.>....vvv..>.v...v.v>v>.v.vv>..>.>v.v.>vv.v..>....v...>v.v>........>v>vv.v.v.v..>v>....>.>...>....v.v.>>v...>v.>v.v>>>v.v.v>v...>>>.. +>.vvv.v.v>vv.v..v>.>.>.vvvvv.>.vv>vv....v>>>v.>v..v.v.>>>.>>>.>.>>..v......>vv>...>v....>>>>......v>..v>vv..v...v>.>.v..>v.>..>>.v>.>...... +...v......vv.>.>...>v>vvv>>v>...v...>v...v.>....v.v...>vv..vv>v..>vv..v>.>.....v...v....>>...>v>v.vvv>..>>v.vvvvv...>>.v..>v.>.>v>..v>>.>>v +..v>.>..vv>v.>v.>>.>>>...v>vvv>v.v>>v>v>vv..vv...v......v..>.>.v..>.>.v.v.>>.>>>>...vvv..>>v>...v.>...>vv..vv>v.vv.>.v...>vv.>>>>>.>..v>v.> +>.........>.v>.>...>.v>.....>>..v.......>.v>...>>v>.vvv.......vv.>...v.>.v>...>v>.....>...v.>>vvv....>vv>..v>.vvv>...>.v.v...>v.>.v.>.....v +.v.>>>.vv>...>vv.>..vv..>v.>>.>..v.....v..>>>v..>..v>>.....>..v..vv.....v>......>v>vvv.vvv>>.>...v.>.v>.>v....>>>.......>..>>vv...>...>..>. +..>v>>...vv>.>>v.>.>.>vv.>>v...>..>v>..v>v>vv.v...>v>v.>..v>.v>>>.>...v>......v>..>v>v.v.>vv>v.>v.v..v.>..v..>.>v>>....v.>v>>vv>vv..>.....> +.v.>.v>v>...>vv>.vv...vvv.v.v>>..v>>>>..>>...>.vvv....v...>...>..>.>..v...v....>...>>.vv....v.v.>vv>v.>.>..vv>>vv>v>>>v>.>v.v>>..v>.>v..v.. +.>..v..........>.>.vv.vvv.>v...>.vv.v..>v........v..>>vv>..>.v.>..>.>..v..>..vv.v>>v.....>>vv>>.>v.....>...v...>.v.v>.v>..v..>.>.>v>>..>.>. +.vv.>>>v.>.>...vv.v....>vv.>.v>>.v...v.>.>..>>>..>vv.>>..vvv.>....>>>..>v....vvv.>>.>.v>...>>...v.>..v...v.>>>.>>>..>>....vv.vvv.v...v..>.v +v>.v>.>...v>vvv.vv.v..v.v.v>.>.vv.>.>...v>>.v..v>...>>.v.........v>>vvv.v>.v>v...v..v>>>.v.>.>>>>v.......>vv..vv..v.vv>>...>vv.v..v.v...... +>>.v>..>.>.>>...>...v..v>.v...v.>.>.v..vv....v..v.v>.>>.>>>v....>.>.v.>>>v....v>.>......v>..>>>v.>..v..vv>.v>>....>v>v....>v.>.v..>....vvvv +.vvv>>.v.>..vv..vvv......>.v>v.vv.>v>v.>>>..>v>...v.>.>vvvv......>vvv.v..>v.v..>v...v>>..>vv....v..v>v>....vv>..>.>....>....>v.vv.v>>.>>.v> +>.vvvvv..>v>v.>..v>.v....v..>..v.vv.>v>>>v>>v....>v....>v.>v>...>>vv.>...>v..>....>.>.v..v.>.v>>...vv.>.v.v>>v....vvv..v>....v>v.>v.>.v..>. +.v>.>v..>.v..>v.v...v.vv>....v.v>vv>.vvv>.>>.v.>v>>..>>>vvvv...>.>vv....v..v>.>.>...v.v>v>>..>v.v>v.v>>.>.v.>v>..v..>v>..>...>..>vvv>.v>..v +>.>.vv>.>>.>v>v>>>.>.>.>v..v..vv...>..........v>vv.>v..>..v.>v..>..v>.v>......>.v...v..v.v.v..v..>>..v..v>...v>vv>v.>>v.>>..vv...v.v>vv.>v. +...>v..vv>v..>>.vv>>.v..v>>...>.vvvv>..v.>v...>..>v.v...v.>>>.v...>>..v.>>.>....>.v.vv..v>....vv.v..>..vv..>....vv.v.v>.......v.>v.vv.>v>.. +.v.v...>v......vvv>..>.v..>>..v..>v..>..v.>.>>.>.>.vv..>...>..vvv.>..v....v>v.>>.>>...>......vvv.vv....>>....>v.v>v>>>vv.>..>v...v.v.>....> +v.>.v>.>>>.v...>>.....v>...>v>>v..>..v....>>v.vv..>.v...>.>.>v..v.>.>..>v>>..v.>.>v>v>.>>.v.vvvv.v.>..>vv.....>>v....>.v.>>....>...>.v..vv. +v.vvvvv.v.......>..v>.v>v...v.>>>..>..>>>>..v..v..v...>....vv>v.v>......>.....>>>...v...v>vv>v>>.v.>.v...v.v>.v.>v..>..v.......vvvv.v.>v.>. + diff --git a/src/25/part1 b/src/25/part1 @@ -0,0 +1,307 @@ +--- Day 25: Sea Cucumber --- + +This is it: the bottom of the ocean trench, the last place the sleigh keys could be. Your +submarine's experimental antenna still isn't boosted enough to detect the keys, but they +must be here. All you need to do is reach the seafloor and find them. + +At least, you'd touch down on the seafloor if you could; unfortunately, it's completely covered by +two large herds of sea cucumbers, and there isn't an open space large enough for your submarine. + +You suspect that the Elves must have done this before, because just then you discover the phone +number of a deep-sea marine biologist on a handwritten note taped to the wall of the submarine's +cockpit. + +"Sea cucumbers? Yeah, they're probably hunting for food. But don't worry, they're predictable +critters: they move in perfectly straight lines, only moving forward when there's space to do so. +They're actually quite polite!" + +You explain that you'd like to predict when you could land your submarine. + +"Oh that's easy, they'll eventually pile up and leave enough space for-- wait, did you say +submarine? And the only place with that many sea cucumbers would be at the very bottom of the +Mariana--" You hang up the phone. + +There are two herds of sea cucumbers sharing the same region; one always moves east (>), while the +other always moves south (v). Each location can contain at most one sea cucumber; the remaining +locations are empty (.). The submarine helpfully generates a map of the situation (your puzzle +input). For example: + +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> + +Every step, the sea cucumbers in the east-facing herd attempt to move forward one location, then the +sea cucumbers in the south-facing herd attempt to move forward one location. When a herd moves +forward, every sea cucumber in the herd first simultaneously considers whether there is a sea +cucumber in the adjacent location it's facing (even another sea cucumber facing the same direction), +and then every sea cucumber facing an empty location simultaneously moves into that location. + +So, in a situation like this: + +...>>>>>... +After one step, only the rightmost sea cucumber would have moved: + +...>>>>.>.. +After the next step, two sea cucumbers move: + +...>>>.>.>. +During a single step, the east-facing herd moves first, then the south-facing herd moves. So, given +this situation: + +.......... +.>v....v.. +.......>.. +.......... + +After a single step, of the sea cucumbers on the left, only the south-facing sea cucumber has moved +(as it wasn't out of the way in time for the east-facing cucumber on the left to move), but both sea +cucumbers on the right have moved (as the east-facing sea cucumber moved out of the way of the +south-facing sea cucumber): + +.......... +.>........ +..v....v>. +.......... + +Due to strong water currents in the area, sea cucumbers that move off the right edge of the map +appear on the left edge, and sea cucumbers that move off the bottom edge of the map appear on the +top edge. Sea cucumbers always check whether their destination location is empty before moving, even +if that destination is on the opposite side of the map: + +Initial state: +...>... +....... +......> +v.....> +......> +....... +..vvv.. + +After 1 step: +..vv>.. +....... +>...... +v.....> +>...... +....... +....v.. + +After 2 steps: +....v>. +..vv... +.>..... +......> +v>..... +....... +....... + +After 3 steps: +......> +..v.v.. +..>v... +>...... +..>.... +v...... +....... + +After 4 steps: +>...... +..v.... +..>.v.. +.>.v... +...>... +....... +v...... + +To find a safe place to land your submarine, the sea cucumbers need to stop moving. Again consider +the first example: + +Initial state: +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> + +After 1 step: +....>.>v.> +v.v>.>v.v. +>v>>..>v.. +>>v>v>.>.v +.>v.v...v. +v>>.>vvv.. +..v...>>.. +vv...>>vv. +>.v.v..v.v + +After 2 steps: +>.v.v>>..v +v.v.>>vv.. +>v>.>.>.v. +>>v>v.>v>. +.>..v....v +.>v>>.v.v. +v....v>v>. +.vv..>>v.. +v>.....vv. + +After 3 steps: +v>v.v>.>v. +v...>>.v.v +>vv>.>v>.. +>>v>v.>.v> +..>....v.. +.>.>v>v..v +..v..v>vv> +v.v..>>v.. +.v>....v.. + +After 4 steps: +v>..v.>>.. +v.v.>.>.v. +>vv.>>.v>v +>>.>..v>.> +..v>v...v. +..>>.>vv.. +>.v.vv>v.v +.....>>vv. +vvv>...v.. + +After 5 steps: +vv>...>v>. +v.v.v>.>v. +>.v.>.>.>v +>v>.>..v>> +..v>v.v... +..>.>>vvv. +.>...v>v.. +..v.v>>v.v +v.v.>...v. + +... + +After 10 steps: +..>..>>vv. +v.....>>.v +..v.v>>>v> +v>.>v.>>>. +..v>v.vv.v +.v.>>>.v.. +v.v..>v>.. +..v...>v.> +.vv..v>vv. + +... + +After 20 steps: +v>.....>>. +>vv>.....v +.>v>v.vv>> +v>>>v.>v.> +....vv>v.. +.v.>>>vvv. +..v..>>vv. +v.v...>>.v +..v.....v> + +... + +After 30 steps: +.vv.v..>>> +v>...v...> +>.v>.>vv.> +>v>.>.>v.> +.>..v.vv.. +..v>..>>v. +....v>..>v +v.v...>vv> +v.v...>vvv + +... + +After 40 steps: +>>v>v..v.. +..>>v..vv. +..>>>v.>.v +..>>>>vvv> +v.....>... +v.v...>v>> +>vv.....v> +.>v...v.>v +vvv.v..v.> + +... + +After 50 steps: +..>>v>vv.v +..v.>>vv.. +v.>>v>>v.. +..>>>>>vv. +vvv....>vv +..v....>>> +v>.......> +.vv>....v> +.>v.vv.v.. + +... + +After 55 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv...>..> +>vv.....>. +.>v.vv.v.. + +After 56 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv....>.> +>vv......> +.>v.vv.v.. + +After 57 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv.....>> +>vv......> +.>v.vv.v.. + +After 58 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv.....>> +>vv......> +.>v.vv.v.. + +In this example, the sea cucumbers stop moving after 58 steps. + +Find somewhere safe to land your submarine. What is the first step on which no sea cucumbers +move? + + diff --git a/src/25/src/main.rs b/src/25/src/main.rs @@ -0,0 +1,100 @@ +use std::collections::HashMap; + +#[derive(Hash,PartialEq,Eq,Clone)] +struct Pos { + x: usize, + y: usize +} + +fn parse_input(input: &str) -> (HashMap<Pos,char>,usize,usize) { + let mut map = HashMap::new(); + let mut y: usize = 0; + for line in input.lines() { + if line.is_empty() { continue; } + for (x,c) in line.chars().enumerate() { + if c == '>' || c == 'v' { + map.insert(Pos { x, y }, c); + } + } + y += 1; + } + let width = map.iter().map(|(p,_)| p.x).max().unwrap() + 1; + return (map,width,y); +} + +fn printmap(map: &HashMap<Pos,char>, width: usize, height: usize) { + if aoc::get_debug() == 0 { return; } + for y in 0..height { + for x in 0..width { + let pos = Pos { x, y }; + let res = map.get(&pos); + if res.is_some() { + aoc::debug!("{}", *res.unwrap()); + } else { + aoc::debug!("."); + } + } + aoc::debugln!(""); + } + aoc::debugln!(""); +} + +fn walk(map: &HashMap<Pos,char>, width: usize, height: usize) + -> (HashMap<Pos,char>,usize) { + let mut nmap: HashMap<Pos,char> = HashMap::new(); + let mut moved: usize = 0; + + for (p,c) in map.iter() { + if *c != '>' { continue; } + + let np = Pos { x: (p.x + width + 1) % width, y: p.y }; + if map.get(&np).is_none() { + moved += 1; + nmap.insert(np, '>'); + } else { + nmap.insert(p.clone(), '>'); + } + } + + for (p,c) in map.iter() { + if *c != 'v' { continue; } + + let np = Pos { x: p.x, y: (p.y + height + 1) % height }; + let res = map.get(&np); + if (res.is_none() || *res.unwrap() != 'v') && nmap.get(&np).is_none() { + moved += 1; + nmap.insert(np, 'v'); + } else { + nmap.insert(p.clone(), 'v'); + } + } + + return (nmap,moved); +} + +fn part1(aoc: &mut aoc::Info) { + let (mut map, width, height) = parse_input(&aoc.input); + + let mut answer: usize = 1; + loop { + printmap(&map, width, height); + let (nmap,cnt) = walk(&map, width, height); + aoc::debugln!("{} {}", answer, cnt); + if cnt == 0 { break; } + map = nmap; + answer += 1; + } + + aoc.answer = Some(format!("{}", answer)); + aoc.solution = Some(""); +} + +fn part2(aoc: &mut aoc::Info) { + aoc.answer = Some(format!("")); + aoc.solution = Some(""); +} + +fn main() { + aoc::run(part1, part2); +} + diff --git a/src/25/test1 b/src/25/test1 @@ -0,0 +1,10 @@ +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> +