--- 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
data Path = Path String -- current cave
[String] -- caves visited
- (S.Set String) -- closed set of small cavees visited
+ (S.Set String) -- closed set of small caves visited
(Maybe String) -- the small cave we've visited twice
deriving (Eq, Ord, Show)
type Graph = M.Map String (S.Set String)
-
main :: IO ()
main =
do text <- TIO.readFile "data/advent12.txt"
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