Done day 25
authorNeil Smith <neil.git@njae.me.uk>
Sun, 24 Apr 2022 14:13:49 +0000 (15:13 +0100)
committerNeil Smith <neil.git@njae.me.uk>
Sun, 24 Apr 2022 14:13:49 +0000 (15:13 +0100)
advent-of-code21.cabal
advent25/Main.hs [new file with mode: 0644]
data/advent25.txt [new file with mode: 0644]
data/advent25a.txt [new file with mode: 0644]
problems/day25.html [new file with mode: 0644]

index 5727015b47a49e2d9542cf203cf0b557238ef37f..d97a3b0f19ca0314358f4ef7447a2ab7394a573b 100644 (file)
@@ -245,3 +245,9 @@ executable advent24d
   import: common-extensions, build-directives
   main-is: advent24/MainDelay.hs
   build-depends: text, attoparsec, containers
+
+executable advent25
+  import: common-extensions, build-directives
+  main-is: advent25/Main.hs
+  build-depends: linear, containers
+  
\ No newline at end of file
diff --git a/advent25/Main.hs b/advent25/Main.hs
new file mode 100644 (file)
index 0000000..5c9d005
--- /dev/null
@@ -0,0 +1,96 @@
+-- Writeup at https://work.njae.me.uk/2021/12/12/advent-of-code-2021-day-11/
+
+import qualified Data.Map as M
+import Data.Map.Strict ((!), (\\), (!?))
+import Linear (V2(..), (^+^))
+import Data.List (unfoldr)
+
+type Coord = V2 Int -- r, c
+data Grid = Grid (Coord, Coord) (M.Map Coord Cucumber)
+  deriving (Eq, Show)
+
+data Cucumber = Eastwards | Southwards
+  deriving (Eq)
+
+instance Show Cucumber where
+  show Eastwards = ">"  
+  show Southwards = "v"
+
+main :: IO ()
+main = 
+  do  text <- readFile "data/advent25.txt"
+      let grid = mkGrid text
+      print $ (1 +) $ length $ simulate grid
+
+mkGrid :: String -> Grid
+mkGrid text = Grid (V2 0 0, V2 maxR maxC) 
+    ( M.fromList 
+      [ (V2 r c, mkCucubmer r c) 
+      | r <- [0..maxR], c <- [0..maxC]
+      , isCucumber r c
+      ]
+    )
+  where rows = lines text
+        maxR = length rows - 1
+        maxC = (length $ head rows) - 1
+        isCucumber r c = ((rows !! r) !! c) `elem` (">v" :: String)
+        mkCucubmer r c = if (rows !! r) !! c == '>' then Eastwards else Southwards
+
+delta :: Cucumber -> Coord
+delta Eastwards = V2 0 1
+delta Southwards = V2 1 0
+
+wrap :: (Coord, Coord) -> Coord -> Coord
+wrap bounds@(V2 r0 c0, V2 r1 c1) (V2 r c)
+  | r > r1 = wrap bounds $ V2 r0 c
+  | r < r0 = wrap bounds $ V2 r1 c
+  | c > c1 = wrap bounds $ V2 r c0
+  | c < c0 = wrap bounds $ V2 r c1
+  | otherwise = V2 r c
+
+ahead :: Grid -> Coord -> Coord
+ahead (Grid bounds cucumbers) here = wrap bounds (here ^+^ (delta c))
+  where c = cucumbers ! here
+
+vacant :: Grid -> Coord -> Bool
+vacant (Grid _ cucumbers) here = M.notMember here cucumbers
+
+canMove :: Grid -> Grid
+canMove grid@(Grid bounds cucumbers) = Grid bounds $ M.filterWithKey openAhead cucumbers
+  where openAhead here _ = vacant grid $ ahead grid here
+
+blocked :: Grid -> Bool
+blocked grid = M.null cucumbers 
+  where Grid _ cucumbers = canMove grid
+
+eastFacing, southFacing :: Grid -> Grid
+eastFacing (Grid bounds cucumbers) = Grid bounds $ M.filter (== Eastwards) cucumbers
+southFacing (Grid bounds cucumbers) = Grid bounds $ M.filter (== Southwards) cucumbers
+
+advanceEastwards, advanceSouthwards :: Grid -> Grid
+advanceEastwards = advance eastFacing
+advanceSouthwards = advance southFacing
+
+advance :: (Grid -> Grid) -> Grid -> Grid
+advance facing grid@(Grid bounds cucumbers) = Grid bounds $ M.union cannotMove advanced
+  where Grid _ advancing = facing $ canMove grid
+        cannotMove = cucumbers \\ advancing
+        advanced = M.fromList $ map advanceOne $ M.toAscList advancing
+        advanceOne (here, c) = (ahead grid here, c)
+
+step :: Grid -> Grid
+step = advanceSouthwards . advanceEastwards 
+
+maybeStep :: Grid -> Maybe (Grid, Grid)
+maybeStep grid
+  | blocked grid = Nothing
+  | otherwise = Just (grid', grid')
+  where grid' = step grid
+
+simulate :: Grid -> [Grid]
+simulate grid = unfoldr maybeStep grid
+
+showGrid :: Grid -> String
+showGrid (Grid (V2 minR minC, V2 maxR maxC) cucumbers) = 
+  unlines $ [ concat [showCucumber (V2 r c) | c <- [minC..maxC] ] | r <- [minR..maxR] ]
+  where showCucumber here = maybe "." show $ cucumbers !? here
diff --git a/data/advent25.txt b/data/advent25.txt
new file mode 100644 (file)
index 0000000..09a45d9
--- /dev/null
@@ -0,0 +1,137 @@
+v>>>.v..v.>.>.....>>.vv>v.v>...vv>>...vv...>..>.vv.>>vvv..vv.>v..vvv>.>.v..>.>....>..vv>.>v..v>v>v.v....>v..>..>..>..v..v>.v...v>v.v>v.v>.>
+.>.v..>>>.v....>.>...v.>>.>v..v.v...>.....>.>....>.>>>.vv>.>.>..>..vv..>vvv...v.....v....>....>>vv>.vv.>.>.v>....v.>>v.>.>v..>>>..v>.v.>...
+.v..>>....v>v..>>.>.v>.>..v>>>v>.v..v.>>vv.v....>.>>>.>>>.>.>.v>..>.>...vv..>>...>.>v>vv>.v>......>v...>v.>>.v>v>...>v...v...v...vvvv>..v..
+v.>...v>..vv.>..v>>....>.>v>>vv>>v>>v>v>..vv>..>.>.vv>.>.v>...>.vv>.v>.vv..v.>...>.v>.vvvv>.>>....v>...>v>.>v>>>.vv.v>.>v>.v.>>v...vvv..>>.
+.vv>.v....>.v>.v.v..>>..v>vv>>v..>v...>..vvv.>v.>v.v..>.v.v.v.>.>>.>>>...>.v>v>>>.vv>..>v.v.>v.>...>....vv>.>.>......vv>v.v>>.vvv.vv.vv>.v.
+>.>.v>.v>v.v.v.>.v>v...v>>..>>>>.v>.....v.v>>v.vv.vvv.v.v......v..>.v.v.....v.v..>v..>>>v.v..>v....v>..>v>v..vv...v.v.v.>>..v.>v>>..>v.v...
+vvvvvv.>>.v>.v.v.>..vvv..v.v.>..v.>>>vv...v...>vv>..v.>vvv>v...v>>..v.v>...v.>v....v>.vv..>v>v...v.....v..>v.v.....v...>.vv.v..vv.>>v>>>...
+.vv>.>.v..>.>vv.vvv>..>...v...>..>...>>>>v>..>>.v..>>...v.v>>>>.>.>.>.>v.vvv...>.>.v>>>.>>v.>>..>..v....v.>>......v..v.>.>vvv....>..v.vv>>>
+.>v....vv>v>v..>v>.v..v>v..v>v>.>.vv>v>vv.>v>...>>.v.>>v.v>.>>.>>....>>v>.>v..vv..vvvv..v>v>v.v>....>.v.>.v.>.....>>vv>>.v..v>>>..v.v...>v.
+.>.>.>>v.v..>>.>.>>...v.v.>...v.>v>>>..>.>.v.>..>>v>>vv.v.>>>.>>.>.>>>>v..v>>v..>....>....>.....>.>..v...>vvv>v.v...vv.v..v..>>vv>>.>v..>>>
+>..v....>>...v....>....v.>>>..>.v..>..vv>>v>.v>vv..>.v>v>v.v....>.vv.>>v...>v.>v>...v>..vv.v.v.v>v>>.v...>>..v>.v...v.vv...>v...vv...vv>v.v
+v>v..>v>v..v.>.>>..v..v>v>>..v..v..v..>>.v.>..v.v.v>v>..>.>v..>vv>.v.>..v.v.v....vvv.v.v.>.v....v.>..>v.......>>v>>.v.......v.vv.>....>.>>.
+v..vv.vvv>>v>.>v..v>.v>.v.v>>v.....v.vv.vvv.>v>..>..>.v....>>>.v>>.>v>.v..v..>>.v..vv>.v.vv..v.....v..>.>>v.v>.>.v....>..v>..>..v....v..v.>
+.>.>>v>..v.>.......>>vvv.vvv.v>..>.v>vvv..vvvv..vv..v...>...vv.v.>.v.>..v.>v>v>vv......>..>v.v....>.v.v>.>>..v>.>>.>...v>..v>>.vv>v...>v..>
+.>..v...v....v.>vv.vv..v>.v.v>>..vvv>>>..v>>.>v.v.v..>.....v.vv>>.v...v..v...v>...>.v....v>v.vv.v.>.>.>..vv..>>vvv..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..vv>..>vv>>>v.>..v>v.>v>....vv
+.>>>..v.>>v>>....>.>.>v..v..>v.>.>.v.v..>...>>v>..v>..v>.....>..v.v......vv....>.>>.v>>.>vvvv..>v..>..v>>v>.....>vv>vv>.>>.v..v>v.v...>>.>.
+....>.>...vv.>>.>.>>.v..>.>>.>.v>.v>v....v..v>....>....>vv...>>.>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.>..vv>..v>.vv>>.v>.>..vvv.v...v.v>.v>.....v...>..v.>.v...v..>.v...v>>.v>..v.v...>v...v..v.v>v>..>.
+vvv.v>.>>>..v>..vv.vv.>>v.>>..>.>v>>>>vv..v.>...>v>....>v>.v>.>>>.>v.>.>.vv.v>..v...>>>...>v.>...>>...>.>..>.v.>v.v..>.v>..>...v.>.>.>...>.
+.v..v.....>..vv.>.v.>>.>>>v.vv>...>..v.....>.v..>.>>..vv>>>...vv>v.>v..>>v.v.v>.v.>>v.vvv....>>.>vvvvv.>>>.>..>v>.>>.>.>.....>>.>...>.v..>>
+>..v...v>...>v.>....vv>.vv...vv...v>v>v.vv.v>vv.vv.>>vv>>...>.v>..>v...v......>..>.v......>.>v>>vv.v...v.>.......>v>.v>.v...v.>....v.>>..v.
+.>v>.vv...>..>..v.vv.>.>.......v.>>>>>.>>.>>.v.v.>>...>.>...v...>.v.>>.>v>>......vv.>v.>.>>>.v..v........>.>.....>....>>.>>.>.>vv...v..vv>>
+..>..v>..v.v.>vvv>.......>.vvv.>..>..>.v.v.>......>......>>..v.>v.>>vv>vvv.v...vvv.>v..>vv.v..v>.v>.>>....>..>..>..v..vv.v>>.v...>.v..vvv.v
+>..vv..vv..v..v...v..>v>>v>.v....>....>..>vvv.v.v...v..v.v>..>v.v.v.v.v>v..>vv...>.>v..v>.>>...>..>..>v.v..v..>.>......>>>.v>...v.v>>v>....
+v.v>v.>>>.v...>.vv>v>.vvv>..>..v>.v.>.v>...>>..vvv>>...>....v.v..>.v.....>v..>.v.vv..vv>.>.>..>...vv...v.>>>>..>>..v.v>>...>.vv>.vvv.>...>v
+v>.>>.>..v.......v..vvv>v.>....v..>...v.v.v>>.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.vv>>.v>.vvvv.v..v.>>v>.>.>...v..v.v>...>.>vvv>>>.v.>.>.v>vv.v.v..>....>.v.>>.>vv..v.>.v.
+>.v.v>v>>v>v..v..v..vv>v>v..>>>.>.vv....vv>v..>.>>...>>...>..v.>......v...>.>.v.vv>.vvv...>.>.v>....>>..>>..v.v....vv...v.v>>.>.>.>.vvvv>v.
+....>.v.>v..>....v..>..v..v....>.vv.....>.>>.v.>>.....vvv.v.>..>v.vv>..>..>v.....>vvvvv>.v.v>>..v.>.v.>..v.>.v.>...>...v.vv>.>.v>v....v...v
+>v>...v..vv..v>.>v>>>>.>>...v>.>>..vv.>>...>v..vv.>..>...v.>v.>..>..v..>..vv.>..>v..>.>..>..v.>.>>>...........>v>v>v.>vv>....>..>vv.vv>v>>.
+>v.v.v>>>.>.>..>.>vv...v>>>...>vv..>...vv..>v>.v..v.>..>>>.>v.>v.>..>.vv..>v.v>.>.v>...>>.......>>.vv...v.>v.>v...vv..>.v>>..>v.>..>>>..v..
+..>.v>...v....vv>...>..vvv.>vv>v...vv.>.v...v...>.>v...>.v.v.>.v>v..v.>v>..v.v...vvv>..>...v.v.v......>v.v...>v.>.v.>v.v.....v>.>..v...v.>.
+....v.>vv>.v.>....>vv>.....v.>....>.v..>>....v.>v.v..>...v..>...>v..>.v..v.>.v.v>v>v>...vv>..>vv>.v>.>...>.v.>v.........v>.>v.v.....v>>v.v>
+vv..>..>.>.>...vv..>v.vv>...v..>v..>v>>.>..>.>.>>>.>....>...>v...>..>.v..>.>>...v..>>v>.>.v.v..v..>>>>.>>.v>>>..>vv..v>.>..>.>v..>.vv...v.v
+.....>>....>v.vv..v.>v>..>......vvv>...>>.v...>...v.v.>..>vvv.vvv.v.>..vv.>..>.vvvv>v>..>>...v.vv.....>v..v...v>.v....>..>>.v>.....v..v>..>
+..>.>......vvv.v>v.>.vv..v..vvv>vvvv>>.vv.>..>v>..vvvv..vvv..>>v...>v..>..>.....>v.vv>v>.v>>.....vv...v..>..>..>v...vv.vv.>vv.>..>.v>..>v..
+.vv...>..v.v....>.........v...>.>vv..>>>v.>v..>.>v>....v>.>...v...>...v.>v.v......v>vv.>.>...v>..>>vv>>v.v.>v>.v>.........>.>>..>v>..v..v..
+vv..>.>.>v>>...vvvv..v>vvvvv.vv..vv.v.v>.>v...>.>v....>...vv>.....>.v..>.v>>..>.>v..>vv...>v..>>...>.....>.>..v>.>>v>>..>v>>v.v...>....vv..
+>>..v>..v.v..v>v>v>>v.>...>.>....vv.>..v.v.>vv.....vv>vv.>...>..>vv.>v.....v..v...vv..v...vv.v>..v.>v.>vv>.>>.>..>.v>..v>...>vvv.v>..v.>.>.
+>.>..v.>>....>.vvv.v..>v.....v>.>.>v..v..v>>v.v>..v>>vv...>...v.>v....vv.....v>....v.>...vvvv..>.....v>v>......v>..>v....v>.......>>..vv>.>
+.>.v..v>>.>..>>>>.v>.vv.v.v..v....>>>>.>.>v.v>>v>..>.v.>.>.v>v.>v...vv.v>.>>v..v....>>>..v>.vv>>>.>.v...>>.>....v..>>..v>..>..>..>v>v>>.vv.
+>>v>v>.>v.>>...>.>...>>..>>..v......v>>vv.vvv.>..>...v>>..vv>...vvvvv>.v.>v.>..>>>>.v>..>.v.vv.>.v......>>.....v.>vv.v.vv..>..>.>...>>..>>.
+..>v...>v..>..>.v..v....v>vvv.>>v..v>>>..v>>...>.v>...>......vv.v..v>>v>.....>vv.v.>.v.>.>...vvv....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....vv.>.v....v..>v>v
+..>>v>>..v.>>.>v>.>v.>.>v>vv.>>.>>>v...>.v.>>>..>..>..v.vv>.>.v...vv..v>>v..>.>vv.>.vv.>>>.vv....vvv>..>>>v......v...>v.vvv>.v....v...v.>.v
+..>..vvv...>>...>....v...>v>>v>>.>vv..>>.v>.....v....v>.....>>v...>v>..v.v.v>....>.>...>..>...>..>>v.v>v>>>..>v.vvv>.>.>.>>v>>>v>.v>>.v>.vv
+....>..v>vv.>>..>.v.vv..v...>.>..v>v>....>>..v.>....>.....v.vv.v>>>vv..>>>vv>..v.>...v.v.v...>...v....v.....v..v.>v.....>v.v.>.v..v>v>>.>.>
+v.>vvv.vv>.>vv>.>.>...>....>.v>.>v>..>v>>vv>....v>.v.>..>>.>>..>>>...v>...v.....v..v.v....>.>.vv>vvv.>.v..v>..v>.>.>>v.v.>v>v.>.>..>>.>>..>
+.v>.....>.v>..>>...>v.>vvv>...vvvv...>>>>>v>.v.>..vvv>v..v......>>>vv.vvv>.......>.v.v.v.>>.....>.v.v..v>....v.>.vv.>..v.>>.v>....>.vvv.v>.
+v.vvvv>.>.>..>vv>......>>v>v.>......vv>.v.v..>vv..v....>.>>.>v.......>.>..vv>.v.v..>.>v.>>v>.>>>>v.>v..v...>..v.v>.v.>>v>>.v.v.v.v>v..vvv..
+>.>.>.v..v.v.v>>.vv.v.>..>>>.>.v.>.>....v.>v.>..>..vv...v..v...>>..>>..v>vv>..>.v....vv.>..v>.>.v.>....>.>...vv...v>.v>..>.....>>>.>>>>v>>.
+>.v....>...>..>..>v>>.>v>v....vv.v>>vvv.v.>>v>vvvv>.vv>>..vv>.v....>>>.>vv>vv..v.>v.>..>......v.v.v>.vvv.>...>>...>>.....v>.v>...>v..v>...>
+.>.>>.>.>.....>>>v..v>..v>....>v>>.>.v.v...v>vv>.v....v.>v.>.vv....v>v..>>v.v.v.>vv>.vvv.>....>.v.....v>v.vv.v>vv..v>.v..>..v>v.......v..>.
+>v.vv>.>>.>>.>>>....>vv.vv>vv>v.>v.>.v.>>>v..v>vv.>..v>...>.v...>>.vv.>>v.v>..>>>..>.v.>>.v..v>.v>v>.v..v...>v.......vv.vvv.v.v>.......vv..
+v.v...v.>>v...v.>v.vvv>>v>v.>>...v>>>>v.v>.v>vv..>>>>v.>.vv>..v>v>...>>>v..v...>..>v.....v.>>..>.v.>.vv....>>..v...>..vv>.v.vv.v.v>.>.v.v..
+.>.>.>v...>>.>..vv.v..v>>....v...>..>>>.v>>>...vv..v....>v..v...>...vv.v.v..v.>.>>vv.vv.v>vvv..>.v>..>>...v.vvv..v>>...>..v.>vv>.>...v>..>v
+>..v..>v>.v>.v.v>>vv>.vv...v....v.>>v>>v>.v....v>>v..>..>>v.vvv.vv.>>..>v>>.v..vv..>vvv..v...vvv..vv......vvv..>v>>>....>vv>....>.v..v>v>>.
+.>>v.>>..>.>>v.>>....v.v>>.>..v.v.v..v....v>vv>v>..>.>>...>v.vvv.v..>.>..v>.>v>..v.>.v.v.v.>.>......v>.>>..v>>>>>v.vv>..>vvv>v>>>>>.>..v>vv
+v..v...vv..v.vv>....vv..v.v>>v..>>>>.v...v.>>..>...>>......v.v.vv..vv.>>vv...vv.>.vv.>.>..v>>vvv...>v.>v>v.>v.v>.v>v.>>v.>.v.v.vv..v..v>.>.
+.....>>.v..>.v..vvv..>..>.....v.v..>>....>v>vv>.>..>v.v...>v.>..v...>..vv>v.>>..v.>.>.vv>v..>.>.>.......v.>..>......v.vv>.>.vv.>v....v.>...
+v..>>v>>>.....>v.>.v.>v..>...>v.>>.vv>vv>.v>....>.............>.>>>.>.>.v.>v>>..vv>>v.v>vv..v.v..v.>.>..v..>>...v.>.....>.>...vvv..>v..>.>>
+..>...v>...v...v.>.v.>.>..v...>v..vv>>..v.vv.>.>.......v.>.>..vvvv>......>.>..v>>...>>....vvv...>.v>>>...v...v..>v..v>.>.>v..>...v>v.>...>.
+.>v>>>.>>v..v..>.>..........v.>>.>.v.v.>...vv>v.>....>>v.v..v>..>..>.>.>>>v..>.vv.vv>>..v..v...>...>.>..vv.v.>v..>..>...>v.v>vv>v.>>>>>...>
+>.>.>......>>vv>>>..>>>.>..v....v..>......>.>v..v>.>vv....>....v........v>.>v..vv...>>>.vv>>v.v>..vv.>v.v....>v.>.vvv.v>>.vv>.......>.>>>>.
+...>.....vv>...>....v>v>>.v.v.>.v..>.v>.v.>>.....vv.>>.vv.........>.v..>>>.v....v...v.v.v....>vv.v.>.v....vv...v.vv.....>>.......v.v.v...v.
+>.vv>..>v...v..>.v.>>.v.....vv.v.>v..v>.>..v.>>vv.....v>>....>v>....v>vvv...vv...>......v..>......v.v>v.v>.>.v.>v..v>vv..v.>v>>v>v..v.v>>..
+>v.........>v>....v.v.>.v..>>..>>v.>..vv.vv.>v....v.>v>v.>...v.>>...v>>v..v..>..v.>v>v>..v.....>.v..v...v...>..>v>.>vv.....vv>>v.vv>v>v....
+v.>.........>.>v..>.....>...v.>.v.v.>..>.....>..>.v.......v.v.vv........v.>.v.>...v...>>>.>..vv>v..vvv>>..vvv.>>v>.vvv.vv.v.v>.v..>.>v.>>..
+v.v...v.v.>.>.v.>>>vv...>vv...>>>>>..vvv....>>.>....v>v..vv....v.v>>.>>.>v>>..>.>..v..v>.v.....>.>v>v..>...v.vv.....>>..>>>>v.>>>...>..>.>.
+>.v.v>>v.vvv>v....vvvvvv.>.>>>.>...>v>.>v>....>..>.....v..>v>..>.>..v>v.v>..v>.>vv.>...>v..>v.v..>>>>>....vv.vv>vv.>vv.vv.>...>v....v..>>vv
+.>..>..v.>.vv...vvvv..>v.....>.>vvv.v>...v>.>v..>>...v..v>.vv.v.v.>>vv>>..>v>.>v.>v....>.>>.>...>.v.>>.>.v.>>>>.>...>v.>v>.v.vvvv>.vv..>>..
+.>.>.>v..v>....v>vv...>.....v>..>v>v>..v>v.v>..>>>.>.>>>...>v..vv>v>>.v>v>...>.v.>v..>>.>..>....v..>.vv>.>..v..>.>....>v>..>...>vv.>...>v..
+..>.>v.>....v>v>v>..>..>v.v.>.v.>>.>v.vv>v..>.v.v.>.....>..v..v....>...>...>v.>..vv.v.vvv>.v........v.v.>v..v.v.>vv....>v.>.>>.>...>>..>>vv
+>....>>.vvv....v..v.v..>..v>.>v>..v>v.>..v..v....v..>..>...>.>v>v.>.>.vv.>.v>.v..>.>>...v>v.v>>..>>>.vv>.>.>v>>>>v...>.v.vv..v>..>..v>.....
+...>>.v..>.v.v.>.>.>v.v>v.>>v..>.>v...v.v..vvv.....vvvv>....v.vv>..>...vvvv>v.>vv...v.v.>>.>.>v.>v>vvvv.>vv..>>..v.vvv.v...>>>>>>v...>v.>.v
+vv>v.vv..>..v>.v.>>....>..v.....v..>v.vv..>vv>vv>>>v.v.>...vv.v>v..v.>..v...v>.>>..v>..>>vv...v..>>....v.....vv.>..>>..>..>>>>.>......>>v>>
+..>>...v.vv>>..>...v>.v>v..>>>..>v>.v>v.>..>...>>...>>>..v.>v........>...>>..>....>.v.v..>v..vv>>.>vv.vvvv>v.v.vv>>>>.v.v..vv>......vv.v>vv
+v..vv.>v..>.>..>....v>.>.>.>>...>>.v>>v.v.>.>>v>.vvvvvv.v.vvv>.vv>..>....>vv.vv>>>v>.vvv>.....vv...v>..v.v......vv.>.v..vv.>.v.v......v..>>
+vv.v>..>.>v....v...>>>.>..v.v>..v>vv.>>.>..>.>vv.v.v...>v.v>>..........v.v>>>.v.v...>..v..>>.v..>.>.>v>..>>vv.>>v>.v..>.....v...v..v>.>v>v.
+>.>>.....vvv.v>vvvvv.>>..v.v>>v.v..v..vvvv..v....v>>v.v...>.....vv..vv...v>.v.v.vv.vv>v..v.v.>.v.....>....>>....>.v.>>v..vvv.>>>v>.vv>.....
+>>vv>...v>v.v>.>>.>.......v.v>.v..vv>v>v..v.>..>.>.>v...vv.v.vvv>.....v>.>..>.>v..>.>>vv>>.v.v...>.>.>>.v..>...>..>..>.v>.vv.....>.v.>.....
+...>>v.v.vv.v..>.>..>.v.....v.v...vv..>.>>>.>.v>v.>....>v>.v.v...v.>.>v....>v...>v..>>...vv..>>..>>v>>v.v>vv.>....>.>>v.v..>..v..>v..vv>...
+.v.>>v..v>>vv..v>v.vv>....>v>..v...vv>.>.v>>>...vv..>...>...v..v....v.v>.>..>.>....v.v>v..v.>.>.v>.>..>>>>v.v>.v>..>.......v>vv....vvv.>...
+v..>.....>v.>vv.>>...>>...>...v.>...>v.v..v>.v..>.>.vv.vv>v.v....>>..>vv>..>.v>vv.v>.>>.>>.v..vv>.>.vv.>.>..>..v>.>v.......vvvv>.v.>..v>v.>
+>v>>.>.....>......>..>..>v.....v......vvv...v>.v.>....>.vv..>v.>..v..>>>.>..v.......>..>>.>.>v..v..>v.v>v>....>.>.........>vv...>>v..>v.>..
+>.v.....v......v.>.>v.>..>.>>...>..vv..vv.>......>vv.>.>v>v....>>.>.>v.>v>.vv.v.>..v.>.v.>..v.>>v..........>>.v..v>>.v.v.vv...v.vvvv.>.v>v>
+>.v..>v>.....>...>>v.>.>>>>>>vv>vv>.>.v..>..v..>....>>..>...>...v.v.>>.v.>v.v...v>.v...v>v...>.vv.>.>>>>>>>.v>v>v..>..>v..v.vvv>...>.>..vv.
+.>.>>>.vv...>.v....v..v>.vv.vv>.v.>>v....vv>>v>>v>.....>.>..v>>...vv>>>v>v>v>...v.>v.......vvv.vv.>...>v....vv.>>>......v.>..vvv.>...>...>v
+...>..v...vv.>>>.>>.>..vv..v.>>v.>..>.vv>.....v.>>.v...v>>...>>.>vvv.>>>>>>v.v>vvv..v...v.....>.v......>.>.v.>.v..>>>>v..vv...>..v>>..>.>..
+.>vv..vv>>>.>....>vv.v....v.vv..v.>v.v.v...>.v>..v.>.v.>v.v.v.>vv...>v.v.>>..>>.>>vv...>...>.v>vvv>v>...v..v.v>v.v>.>vvv>>.>.>...v>.>.>....
+.....>vv...>.>>.vv>vv.v.vv.v.....v>..>.v.....>..>vv..>..v........>.>v....>.>v>v..v>v.>.>>..>vv..v>.>.vvv..v.>>v>v.v>.>>>>>...vv.>......vv>v
+>vv.v.....v..>>v.>>..v>>.>..vv.....v.v...>v.v...vv>.vvv.>..v.>..v..v>.v.v>v>.v.>>..>vv.>vv.>....vv>vvv.v..v..>vv.vvv...v>v..v.v.v.>....v>.v
+.>....v......v..vv.>.v>v.v...v.v>...v.>..>v...>.v...>.>v...v>.>..v.v.>>>vv.>.v>v>vv..>>.v.v..>vv.>..v>v..v>vvv....>vv.......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>..vvv>....v>.>>.>v..v
+vv.vv.vv>.>>>>>v>>>....>.vvv.>..v.>...v>>.>..vv..>>v...>.v..>v>.v...v..>..>>v>>>...>.v.>v...vv..vv..>v.>..>vvv.>..vvv.v..>>>..v>v.v.>.v>>>.
+.v...>..v.v>......vvvv>vv>.v>..v...>.>.v>..v..........>vv.>v..>.v>.v...>.v.v..v.....vv>..v..v.v.v..v>.v.>>..>>..vv>>.vvv>...>v>.v>vv.v..>..
+>v...>>v>v..>.>..>.....>>.v....v.>.>vv..>.>.vv.>..>...>....v>.>v>v...>v..>.>>.v>.>.>vvvv>>....v.>.......>..v>v>.>.v..>.....v>..>>..>>>>v.v.
+>>..v.....>.>>v..>v..>>>v>v....vv...vvvv..>.>..>.>v.vvv>>v..>...v..vv...>..v......v>v>.v.v>..v>v>v.>>.>.v.>v.v.>v.>>>.>...v>>.v.>v.vvv>>>.v
+..v>>>..>.>v..vv>.>>.vv..v..v.>>>>vv>vvv..>>v.>>>..>v.vv.>v.>...>....v..>..>>..v>.v..v.v..vv>..>.>v...v>>v>>.>.>...v.v>.>v.v.v.v.vv>v>.v.v>
+..>>.v>.>>.vv......>.>>v>.>>v>..v....>v>v.>>vv....vv.v>.v.>.......>vv.....v.v..v>>..>v...v..>>>...>v..>..v.>>..v....>.>.>.....>..v>v..vvv>>
+....v..v.vv>.v.>.v..vvvvv>.v>.v.>>..>....>.>>..>..v.>.vv...............>vv>..>..>.>>v..>>>..>...>..>vv.>>...>..>.>...v>v.>vvvv....>>.v..>v>
+.v.vv.v.v>>v..vvv>...vv..>..>>..>v>>..>.>....v>v.vv.v.....v.vv.v.>.>..>>.>.v>v.vv>.v...>>..>.>>...vv>v....v...>.>v>v.>v>>..v..>..>.>.vv.v.>
+.>>..v>..v>..v..v..>.>.>.....vvv.v..vv.>..>.v>>.>.v>vv>v......v>..>>>.>>>.>v>.>>>.v>.v.>>.vvv.>.>.vv>>.>vvv..vvv......v>..v.....>.v.v>.vv.v
+...>>>>....v.v.>....>>v>v.>.....>>>>v....>.vv.>.>>>..>>>.>v>....v.v...v...>..>.....>.>.v.vv.v.>vvvv>.>>>...v.>>>v.>>..v.>...>v.v.>....>.>v>
+>>.v.>>>.....>.v>>>.>..v.>>vv..>v......v>v.>v.>v>>>>>>.>..>v.>.>..>.v.vv..>....>vv.vv.vv.v>..vvv.>>>....vv>..>v.>>>.>.v.>.>vv.>v.v..v..>>..
+.>.v.vvvv..>.>vvv>.v.vv.vv..v......>>..v>.v>.vv>.>>v.>v.>v.v>.v.>....>>.>..>v.v>...>>....>vvvv>.>>.>>v>.v.vv.>.>..v.>.v..v.v.vv>>..v....>v.
+>....v..v.>.v.>.>>......>..>v..v.v.vv.v..v.>.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...vv.>.>...>>v>v..>v>..v.v>.....>..v..vvv.v.....>>...>.>>>v>.>>.v.v>.>>.v
+v>v.>.vv>.v>...>...v>v>.>>.>.v>v>vv....>vv..>.vv.>>vv.>....>.v.v..>.>vv.....>.>.>v.>vv>>v>..>>vv..v..>>.>.>...>>.>v..vv..>.vvv>.v.....>.vv.
+>..v.>v....v>.>v...v.>>vvv>.vv>v>v.>.>...>..>v.....v..v...v..v>v.>.v..v>..vvv...vv..vv>.>v.vv>...v....>>.>.>>>v.v..>.>v.....>.....v.vv.v>v.
+>..vv........>>v>v.v...v.....vv..v...v..........vvv.....>....vv>v..vvv.v.v>.>v>v.v......>.v..>..v.....vv.>v.>...>....>....v...v>v..........
+...vv...v>>.v>vv...vvv..v>>.v>..v.v>>v..>...>vvv.>...>.>vv.v.v.>.v....>.v.v..v.>>....>..>vv>...>v...>.v..v..vv.>.>vv>vv>>..vvv..>vv....vv.v
+v..>>..v..vv...>v.v.>>vv>>>.>...>...>...>.>.......vvv.>..>vv>>...>vv..v>>>...>>v>v>>..v.>..>.vv.>vv>>.>..>...vvv..v.vvv..v.>.v.v>...vvvvv..
+>>.....vv...>>.>>.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>vv...
+.>>>...v.v.>>.vvv..>.>...>v>v.>vv...v.>.>v.>>..>>vv.v.......>>.>>..>..v.>..vvv>..v..>v>>....>.>.v>.vv.v..v>.....>.v>.vv.>>...v>>v>.vv...>.>
+.>.>..v.v.vv>..>.>.v.vv..vv..>v.>..v.>>>>..v>.v.v>v.vv.>>v...>v.>.>>.>.vvv.>.>v...v>.>.>...v.>v....>..v.>.>>v.>.>..v..>>vv..vvvv>v>>.v>>..>
+..v..>vvv..>>...>>>>v.v.vv.....>.v.>>vv..v.>.>vvv.>>.v.>.v..>..>>>...v.>v>>>...>>...>>>...vv...vvv...>v>....v...v...>..v>..>.>>>>vvvv...v.v
+.v.v.>v>v>.>>..v...>.v>>.>..>.v.vvv>v.>>v>...v>.vvv.>vv>>.>..>.v.v.v.vv...>....vv....vv>v>v.>..>.v.v.>..vv.....v.>.>..vvv.vvvv>>v...v>.v.v>
+v>.v.v...>...>vv..v...vv.vv>..vv>..vv...>>.v.v>.v>...v.v...vv>>.....v>.>v>>.v...vvv.v.vvv..>>>.vv..v>v>..vv......v>>v.>...>vv.>..vv....>>..
+.v.>.v.>.v..v>.>.>...>...>>>...v.>>...vv.v....vv.>v.>v.>.>.>v>v>.>..>>v.>>....v..v...v.>>.>v.........>..>.>.v>vvvv.vv.>v.v>..>..vv.>>>..>>>
+v..>.v.>.v>v.vv...v>>.v.>...>>>v.v.>...>>.>>.>..v....>.>v.>>vv>........v..v.>...v>>>..vv..vv>vv.>v.....v....v.>..>.v...v.vv...vv.vv>.......
+.v..>.>>.>.>>>v>..v>..v.>>>v>...v>>v.>.vv>..vv..v.>>.>.v.>.v..>......>vv.>v.vv>..v>>v........vv.>.v....>vv....>.v....>...v..vv...v.>v.>v>..
+v>...>..v.>..>.>..>v.v.vv.............>.v.>..>...v>v.v>..>vvv.>.v.vv>vv.>v.v>.v..>vv.v>>vv.v..v>..>vv.>.v....v.>>v>.>...vvv.vv>v>..>vvvvv>.
+>v...v..v>v....>v...>v...>.>.>..v.v...v>.>>>.v.v...>.>....>.v..v.>.>..>.>>v.vv.>v...>..v...v...vv...>.>.v.>vv>.>>..>v....>>v.>v.......vv...
+v>.vv>>..v>.>..>...v.>>v.v.>.>>..>.>v.v>>......vv.v..>.vv.>v.v.vv.vvv>v>>.v.>>>....>..v..>.v..>...vv>v.>.v>v.>.>vv..vv.>>.v...>....v>v...>>
+.v...vv...>v.v.v.>.v>vv..vv..v.>>.vvv...>v.vvv.v..vv.>>.>>v>.>v...vvvv>.>.......v>>>>.>..v.>.>v...>v.....>.>>>.>.v.....>..>v....>.>v.vv.v.>
+...v>>.>..v>>v.vv.....>>.>..vv.v>>>......v..>>.>vv>.......v....vv.>>>.vvv.>...>v..>>....vv>.>vv.>>v...>vv.vvv....v....>v>.>..vv>v....v.v.>.
+..>>..v.....>vv.>>.vv>v>..v>vv>..>.>.>v>>.>.>..v...>vvv...>v>.v.>..vv.....v>.v..>.>>.>.vvv>...>v.v.>.>..>.v.>>>.....>v>.>>..>>vv...v.v...v>
+>.v..vv...>v>..vv.>.vv>>.>>.>.>....v...>..vvv....v>....v>.v>..>>.v>>>.v>....>>.>...v...v.>>v.v>...v>>..>v>..v.v..v>...v.v..v.v.>>v..>.vvv.v
+>>>......vvv..v>>.v.....v.v>>...>v>>>>>vv...v.>....>...>>.vvv>>.v.....v...>>.vv...v....v>...v..v>>v..v..>..vv....>>..v..vv>v.>.>vv..v.v.v>.
+>v.>v>v>vv.v>.v.v..vv..>v.>>.>..>...>>...>..>....>..>.v......>>>v.>>>..v.v.v>.v..>..>.vv.v>...>.vv>...v>>.>>....>vv>....v.>...v>.>.v>.>..v.
+.>v....vv....v>.v.>>v.v>....>..v.>..>..vv..vv>..vv>...>>>v.v..>..v.>..vv.vv.>..>...v.>v.>.>v..v.>..vvv>.vv.v>v>.v.v...v....>>>>....vv>>...>
+>..>v>.v.vv..>.v>..vv..v>..v......vv.vv..>......>v.>>....v>>v>>..vv.>.>v..>.v.>>.>...>...vvvv>v>v>..>.v>v>.>>v>.v..vv..>.>v....>>>..>.vv>v.
+...vvv>.v.>v...v.v.>>>v>...vvv..v>....>v..>>..v.v.v>>.v>......v.v.v>vvv>.>..v.v.>>.>.v..vv>v>>v>.vv>v...>v...>.>>....v>>..v.vvv........>.v.
+>..>...>...vv..>.vv>......vv>...v>vv>vvvvv.>>>..........v>.....>..>>.>.>v.v..>.>...>...vvv>>v...>...v.v.v.>.>.>>...>v.v>.vvv>v>....vv.v.v..
+..v>v>>....v..vvv.>...v>..>v..v..v..v.v....>.....>v.>>..vv..>..>vv>...v.....vvv...vv..>.v>vv......>..>.v>>......>v..>.>..>.......v.v.v.vv>.
diff --git a/data/advent25a.txt b/data/advent25a.txt
new file mode 100644 (file)
index 0000000..0f3c0cd
--- /dev/null
@@ -0,0 +1,9 @@
+v...>>.vv>
+.vv>>.vv..
+>>.>v>...v
+>>v>>.>.v.
+v>v.vv.v..
+>.>>..v...
+.vv..>.>v.
+v.v..>>v.v
+....v..v.>
diff --git a/problems/day25.html b/problems/day25.html
new file mode 100644 (file)
index 0000000..c187a2b
--- /dev/null
@@ -0,0 +1,397 @@
+<!DOCTYPE html>
+<html lang="en-us">
+<head>
+<meta charset="utf-8"/>
+<title>Day 25 - Advent of Code 2021</title>
+<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
+<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'/>
+<link rel="stylesheet" type="text/css" href="/static/style.css?28"/>
+<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
+<link rel="shortcut icon" href="/favicon.png"/>
+<script>window.addEventListener('click', function(e,s,r){if(e.target.nodeName==='CODE'&&e.detail===3){s=window.getSelection();s.removeAllRanges();r=document.createRange();r.selectNodeContents(e.target);s.addRange(r);}});</script>
+</head><!--
+
+
+
+
+Oh, hello!  Funny seeing you here.
+
+I appreciate your enthusiasm, but you aren't going to find much down here.
+There certainly aren't clues to any of the puzzles.  The best surprises don't
+even appear in the source until you unlock them for real.
+
+Please be careful with automated requests; I'm not a massive company, and I can
+only take so much traffic.  Please be considerate so that everyone gets to play.
+
+If you're curious about how Advent of Code works, it's running on some custom
+Perl code. Other than a few integrations (auth, analytics, social media), I
+built the whole thing myself, including the design, animations, prose, and all
+of the puzzles.
+
+The puzzles are most of the work; preparing a new calendar and a new set of
+puzzles each year takes all of my free time for 4-5 months. A lot of effort
+went into building this thing - I hope you're enjoying playing it as much as I
+enjoyed making it for you!
+
+If you'd like to hang out, I'm @ericwastl on Twitter.
+
+- Eric Wastl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+-->
+<body>
+<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2021/about">[About]</a></li><li><a href="/2021/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2021/settings">[Settings]</a></li><li><a href="/2021/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <a href="/2021/support" class="supporter-badge" title="Advent of Code Supporter">(AoC++)</a> <span class="star-count">50*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">0xffff&amp;</span><a href="/2021">2021</a><span class="title-event-wrap"></span></h1><nav><ul><li><a href="/2021">[Calendar]</a></li><li><a href="/2021/support">[AoC++]</a></li><li><a href="/2021/sponsors">[Sponsors]</a></li><li><a href="/2021/leaderboard">[Leaderboard]</a></li><li><a href="/2021/stats">[Stats]</a></li></ul></nav></div></header>
+
+<div id="sidebar">
+<div id="sponsor"><div class="quiet">Our <a href="/2021/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://getsturdy.com/aoc" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">Sturdy</a> - Real-time version control for code. Watch us live!</div></div>
+</div><!--/sidebar-->
+
+<main>
+<style>article *[title]{border-bottom:1px dotted #ffff66;}</style><article class="day-desc"><h2>--- Day 25: Sea Cucumber ---</h2><p>This is it: the bottom of the ocean trench, the last place the sleigh keys could be. Your submarine's experimental antenna <em>still isn't boosted enough</em> to detect the keys, but they <em>must</em> be here. All you need to do is <em>reach the seafloor</em> and find them.</p>
+<p>At least, you'd touch down on the seafloor if you could; unfortunately, it's completely covered by two large herds of <a href="https://en.wikipedia.org/wiki/Sea_cucumber" target="_blank">sea cucumbers</a>, and there isn't an open space large enough for your submarine.</p>
+<p>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.</p>
+<p>"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!"</p>
+<p>You explain that you'd like to predict when you could land your submarine.</p>
+<p>"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.</p>
+<p>There are two herds of sea cucumbers sharing the same region; one always moves <em>east</em> (<code>&gt;</code>), while the other always moves <em>south</em> (<code>v</code>). Each location can contain at most one sea cucumber; the remaining locations are <em>empty</em> (<code>.</code>). The submarine helpfully generates a map of the situation (your puzzle input). For example:</p>
+<pre><code>v...&gt;&gt;.vv&gt;
+.vv&gt;&gt;.vv..
+&gt;&gt;.&gt;v&gt;...v
+&gt;&gt;v&gt;&gt;.&gt;.v.
+v&gt;v.vv.v..
+&gt;.&gt;&gt;..v...
+.vv..&gt;.&gt;v.
+v.v..&gt;&gt;v.v
+....v..v.&gt;
+</code></pre>
+<p>Every <em>step</em>, 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.</p>
+<p>So, in a situation like this:</p>
+<pre><code>...&gt;&gt;&gt;&gt;&gt;...</code></pre>
+<p>After one step, only the rightmost sea cucumber would have moved:</p>
+<pre><code>...&gt;&gt;&gt;&gt;.&gt;..</code></pre>
+<p>After the next step, two sea cucumbers move:</p>
+<pre><code>...&gt;&gt;&gt;.&gt;.&gt;.</code></pre>
+<p>During a single step, the east-facing herd moves first, then the south-facing herd moves. So, given this situation:</p>
+<pre><code>..........
+.&gt;v....v..
+.......&gt;..
+..........
+</code></pre>
+<p>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):</p>
+<pre><code>..........
+.&gt;........
+..v....v&gt;.
+..........
+</code></pre>
+<p>Due to <em>strong water currents</em> 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:</p>
+<pre><code>Initial state:
+...&gt;...
+.......
+......&gt;
+v.....&gt;
+......&gt;
+.......
+..vvv..
+
+After 1 step:
+..vv&gt;..
+.......
+&gt;......
+v.....&gt;
+&gt;......
+.......
+....v..
+
+After 2 steps:
+....v&gt;.
+..vv...
+.&gt;.....
+......&gt;
+v&gt;.....
+.......
+.......
+
+After 3 steps:
+......&gt;
+..v.v..
+..&gt;v...
+&gt;......
+..&gt;....
+v......
+.......
+
+After 4 steps:
+&gt;......
+..v....
+..&gt;.v..
+.&gt;.v...
+...&gt;...
+.......
+v......
+</code></pre>
+<p>To find a safe place to land your submarine, the sea cucumbers need to stop moving. Again consider the first example:</p>
+<pre><code>Initial state:
+v...&gt;&gt;.vv&gt;
+.vv&gt;&gt;.vv..
+&gt;&gt;.&gt;v&gt;...v
+&gt;&gt;v&gt;&gt;.&gt;.v.
+v&gt;v.vv.v..
+&gt;.&gt;&gt;..v...
+.vv..&gt;.&gt;v.
+v.v..&gt;&gt;v.v
+....v..v.&gt;
+
+After 1 step:
+....&gt;.&gt;v.&gt;
+v.v&gt;.&gt;v.v.
+&gt;v&gt;&gt;..&gt;v..
+&gt;&gt;v&gt;v&gt;.&gt;.v
+.&gt;v.v...v.
+v&gt;&gt;.&gt;vvv..
+..v...&gt;&gt;..
+vv...&gt;&gt;vv.
+&gt;.v.v..v.v
+
+After 2 steps:
+&gt;.v.v&gt;&gt;..v
+v.v.&gt;&gt;vv..
+&gt;v&gt;.&gt;.&gt;.v.
+&gt;&gt;v&gt;v.&gt;v&gt;.
+.&gt;..v....v
+.&gt;v&gt;&gt;.v.v.
+v....v&gt;v&gt;.
+.vv..&gt;&gt;v..
+v&gt;.....vv.
+
+After 3 steps:
+v&gt;v.v&gt;.&gt;v.
+v...&gt;&gt;.v.v
+&gt;vv&gt;.&gt;v&gt;..
+&gt;&gt;v&gt;v.&gt;.v&gt;
+..&gt;....v..
+.&gt;.&gt;v&gt;v..v
+..v..v&gt;vv&gt;
+v.v..&gt;&gt;v..
+.v&gt;....v..
+
+After 4 steps:
+v&gt;..v.&gt;&gt;..
+v.v.&gt;.&gt;.v.
+&gt;vv.&gt;&gt;.v&gt;v
+&gt;&gt;.&gt;..v&gt;.&gt;
+..v&gt;v...v.
+..&gt;&gt;.&gt;vv..
+&gt;.v.vv&gt;v.v
+.....&gt;&gt;vv.
+vvv&gt;...v..
+
+After 5 steps:
+vv&gt;...&gt;v&gt;.
+v.v.v&gt;.&gt;v.
+&gt;.v.&gt;.&gt;.&gt;v
+&gt;v&gt;.&gt;..v&gt;&gt;
+..v&gt;v.v...
+..&gt;.&gt;&gt;vvv.
+.&gt;...v&gt;v..
+..v.v&gt;&gt;v.v
+v.v.&gt;...v.
+
+...
+
+After 10 steps:
+..&gt;..&gt;&gt;vv.
+v.....&gt;&gt;.v
+..v.v&gt;&gt;&gt;v&gt;
+v&gt;.&gt;v.&gt;&gt;&gt;.
+..v&gt;v.vv.v
+.v.&gt;&gt;&gt;.v..
+v.v..&gt;v&gt;..
+..v...&gt;v.&gt;
+.vv..v&gt;vv.
+
+...
+
+After 20 steps:
+v&gt;.....&gt;&gt;.
+&gt;vv&gt;.....v
+.&gt;v&gt;v.vv&gt;&gt;
+v&gt;&gt;&gt;v.&gt;v.&gt;
+....vv&gt;v..
+.v.&gt;&gt;&gt;vvv.
+..v..&gt;&gt;vv.
+v.v...&gt;&gt;.v
+..v.....v&gt;
+
+...
+
+After 30 steps:
+.vv.v..&gt;&gt;&gt;
+v&gt;...v...&gt;
+&gt;.v&gt;.&gt;vv.&gt;
+&gt;v&gt;.&gt;.&gt;v.&gt;
+.&gt;..v.vv..
+..v&gt;..&gt;&gt;v.
+....v&gt;..&gt;v
+v.v...&gt;vv&gt;
+v.v...&gt;vvv
+
+...
+
+After 40 steps:
+&gt;&gt;v&gt;v..v..
+..&gt;&gt;v..vv.
+..&gt;&gt;&gt;v.&gt;.v
+..&gt;&gt;&gt;&gt;vvv&gt;
+v.....&gt;...
+v.v...&gt;v&gt;&gt;
+&gt;vv.....v&gt;
+.&gt;v...v.&gt;v
+vvv.v..v.&gt;
+
+...
+
+After 50 steps:
+..&gt;&gt;v&gt;vv.v
+..v.&gt;&gt;vv..
+v.&gt;&gt;v&gt;&gt;v..
+..&gt;&gt;&gt;&gt;&gt;vv.
+vvv....&gt;vv
+..v....&gt;&gt;&gt;
+v&gt;.......&gt;
+.vv&gt;....v&gt;
+.&gt;v.vv.v..
+
+...
+
+After 55 steps:
+..&gt;&gt;v&gt;vv..
+..v.&gt;&gt;vv..
+..&gt;&gt;v&gt;&gt;vv.
+..&gt;&gt;&gt;&gt;&gt;vv.
+v......&gt;vv
+v&gt;v....&gt;&gt;v
+vvv...&gt;..&gt;
+&gt;vv.....&gt;.
+.&gt;v.vv.v..
+
+After 56 steps:
+..&gt;&gt;v&gt;vv..
+..v.&gt;&gt;vv..
+..&gt;&gt;v&gt;&gt;vv.
+..&gt;&gt;&gt;&gt;&gt;vv.
+v......&gt;vv
+v&gt;v....&gt;&gt;v
+vvv....&gt;.&gt;
+&gt;vv......&gt;
+.&gt;v.vv.v..
+
+After 57 steps:
+..&gt;&gt;v&gt;vv..
+..v.&gt;&gt;vv..
+..&gt;&gt;v&gt;&gt;vv.
+..&gt;&gt;&gt;&gt;&gt;vv.
+v......&gt;vv
+v&gt;v....&gt;&gt;v
+vvv.....&gt;&gt;
+&gt;vv......&gt;
+.&gt;v.vv.v..
+
+After 58 steps:
+..&gt;&gt;v&gt;vv..
+..v.&gt;&gt;vv..
+..&gt;&gt;v&gt;&gt;vv.
+..&gt;&gt;&gt;&gt;&gt;vv.
+v......&gt;vv
+v&gt;v....&gt;&gt;v
+vvv.....&gt;&gt;
+&gt;vv......&gt;
+.&gt;v.vv.v..
+</code></pre>
+<p>In this example, the sea cucumbers stop moving after <code><em>58</em></code> steps.</p>
+<p>Find somewhere safe to land your submarine. <em>What is the first step on which no sea cucumbers move?</em></p>
+</article>
+<p>Your puzzle answer was <code>435</code>.</p><article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p>Suddenly, the experimental antenna control console lights up:</p>
+<pre><code><em>Sleigh keys detected!</em></code></pre>
+<p>According to the console, the keys are <em>directly under the submarine</em>. <span title="Thanks to the deep-sea marine biologist, who apparently works at the Biham-Middleton-Levine oceanic research institute.">You landed</span> right on them! Using a robotic arm on the submarine, you move the sleigh keys into the airlock.</p>
+<p>Now, you just need to get them to Santa in time to save Christmas! You check your clock - it <em>is</em> Christmas. There's no way you can get them back to the surface in time.</p>
+<p>Just as you start to lose hope, you notice a button on the sleigh keys: <em>remote start</em>. You can start the sleigh from the bottom of the ocean! You just need some way to <em>boost the signal</em> from the keys so it actually reaches the sleigh. Good thing the submarine has that experimental antenna! You'll definitely need <em class="star">50 stars</em> to boost it that far, though.</p>
+<p>The experimental antenna control console lights up again:</p>
+<pre><code><em>Energy source detected.
+Integrating energy source from device "sleigh keys"...done.
+Installing device drivers...done.
+Recalibrating experimental antenna...done.
+Boost strength due to matching signal phase: <em class="star">1 star</em>
+</em></code></pre>
+<p>Only <em class="star">49 stars</em> to go.</p>
+</article>
+<form method="post" action="25/answer"><input type="hidden" name="level" value="2"/><input type="hidden" name="answer" value="0"/><p>If you like, you can <input type="submit" value="[Remotely Start The Sleigh Again]"/>.</p></form>
+<p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
+<p>At this point, all that is left is for you to <a href="/2021">admire your Advent calendar</a>.</p>
+<p>If you still want to see it, you can <a href="25/input" target="_blank">get your puzzle input</a>.</p>
+<p>You can also <span class="share">[Share<span class="share-content">on
+  <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Sea+Cucumber%22+%2D+Day+25+%2D+Advent+of+Code+2021&amp;url=https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F25&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
+  <a href="javascript:void(0);" onclick="var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=I%27ve+completed+%22Sea+Cucumber%22+%2D+Day+25+%2D+Advent+of+Code+2021+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F25'}else{return false;}" target="_blank">Mastodon</a
+></span>]</span> this puzzle.</p>
+</main>
+
+<!-- ga -->
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-69522494-1', 'auto');
+ga('set', 'anonymizeIp', true);
+ga('send', 'pageview');
+</script>
+<!-- /ga -->
+</body>
+</html>
\ No newline at end of file