Day5, add SortedMap

This commit is contained in:
2024-12-05 16:13:12 -08:00
parent 21b03368d4
commit ccbd617671
11 changed files with 268 additions and 42 deletions

View File

@@ -21,12 +21,8 @@ check prob r c (dr,dc) =
else if (get prob (r + 3 * dr) (c + 3 * dc)) /= 'S' then 0
else 1
tail : a. List a List a
tail Nil = Nil
tail (x :: xs) = xs
dirs : List (Int × Int)
dirs = tail $ _,_ <$> (0 :: 0 - 1 :: 1 :: Nil) <*> (0 :: 0 - 1 :: 1 :: Nil)
dirs = tail $ _,_ <$> 0 :: 0 - 1 :: 1 :: Nil <*> 0 :: 0 - 1 :: 1 :: Nil
part1 : Problem Int
part1 (P size text) = go 0 0 0
@@ -70,7 +66,6 @@ run fn = do
text <- readFile fn
let lines = split (trim text) "\n"
-- I'm going to assume it's square for convenience
-- part2 will probably wrap around.
let size = length lines
printLn $ "part1 " ++ show (part1 $ P (cast size) text)
printLn $ "part2 " ++ show (part2 $ P (cast size) text)