projects
/
advent-of-code-21.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d7d6a1b
)
Updated link for day 12
author
Neil Smith
<neil.git@njae.me.uk>
Mon, 13 Dec 2021 20:30:01 +0000
(20:30 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Mon, 13 Dec 2021 20:30:01 +0000
(20:30 +0000)
advent12/Main.hs
patch
|
blob
|
history
diff --git
a/advent12/Main.hs
b/advent12/Main.hs
index a191524eaeee1810f59c0562545b8ecb9c7ef09d..c0228990a9c89f1018f7fd21f0bf9e51a402f4e8 100644
(file)
--- a/
advent12/Main.hs
+++ b/
advent12/Main.hs
@@
-1,5
+1,4
@@
--- Writeup at https://work.njae.me.uk/2021/12/09/advent-of-code-2021-day-8/
-
+-- Writeup at https://work.njae.me.uk/2021/12/13/advent-of-code-2021-day-12/
import Data.Text ()
import qualified Data.Text.IO as TIO
import Data.Text ()
import qualified Data.Text.IO as TIO
@@
-16,7
+15,7
@@
import Data.Set ((\\))
data Path = Path String -- current cave
[String] -- caves visited
data Path = Path String -- current cave
[String] -- caves visited
- (S.Set String) -- closed set of small cave
e
s visited
+ (S.Set String) -- closed set of small caves visited
(Maybe String) -- the small cave we've visited twice
deriving (Eq, Ord, Show)
(Maybe String) -- the small cave we've visited twice
deriving (Eq, Ord, Show)
@@
-24,7
+23,6
@@
type PathSet = S.Set Path
type Graph = M.Map String (S.Set String)
type Graph = M.Map String (S.Set String)
-
main :: IO ()
main =
do text <- TIO.readFile "data/advent12.txt"
main :: IO ()
main =
do text <- TIO.readFile "data/advent12.txt"
@@
-72,7
+70,7
@@
extendPath graph (Path current trail visited returned)
recordResult :: Path -> PathSet
recordResult path@(Path current _ _ _)
recordResult :: Path -> PathSet
recordResult path@(Path current _ _ _)
- | current == "end" = S.singleton path
-- (Path current trail visited)
+ | current == "end" = S.singleton path
| otherwise = S.empty
isSmall :: String -> Bool
| otherwise = S.empty
isSmall :: String -> Bool