X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent08%2FMain.hs;h=5ab2916ced95bbdf93ebe3c6b3e7667f108c33d0;hb=a7b02636b8045a73a4dff090c1b932cfa1afd9bd;hp=90f596d0359e317bf18193900ef62db4df88a5f0;hpb=2112fa6fd0099dabee1c0ed9890ee3a381fbc03c;p=advent-of-code-23.git diff --git a/advent08/Main.hs b/advent08/Main.hs index 90f596d..5ab2916 100644 --- a/advent08/Main.hs +++ b/advent08/Main.hs @@ -103,13 +103,13 @@ desertLineP :: Parser (String, Node) nodeP :: Parser Node nameP :: Parser String -problemP = (,) <$> ((many1 directionP) <* many1 endOfLine) <*> desertP +problemP = (,) <$> many1 directionP <* many1 endOfLine <*> desertP directionP = (L <$ "L") <|> (R <$ "R") desertP = M.fromList <$> desertLineP `sepBy` endOfLine -desertLineP = (,) <$> (nameP <* " = ") <*> nodeP +desertLineP = (,) <$> nameP <* " = " <*> nodeP -nodeP = Node <$> ("(" *> nameP <* ", ") <*> (nameP <* ")") +nodeP = Node <$ "(" <*> nameP <* ", " <*> nameP <* ")" nameP = many1 (letter <|> digit) successfulParse :: Text -> ([Direction], Desert)