X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent02%2FMain.hs;h=e8e8f03e3ca90b5f7f404079e1baec1d13c0d035;hb=14a708ee545a9bd6d81205177ab9baabd29d1894;hp=d33a26b47d23148a156f349075f7e57fccfbbf83;hpb=af2928ada523abf40d427402ba93d11b326d013c;p=advent-of-code-23.git diff --git a/advent02/Main.hs b/advent02/Main.hs index d33a26b..e8e8f03 100644 --- a/advent02/Main.hs +++ b/advent02/Main.hs @@ -1,4 +1,4 @@ --- Writeup at https://work.njae.me.uk/2022/12/02/advent-of-code-2022-day-2/ +-- Writeup at https://work.njae.me.uk/2023/12/02/advent-of-code-2023-day-02/ import AoC import Data.Text (Text) @@ -91,11 +91,11 @@ cubeP :: Parser Cube colourP, redP, greenP, blueP :: Parser Colour gamesP = gameP `sepBy` endOfLine -gameP = ParsedGame <$> (("Game " *> decimal) <* ": ") <*> showingsP +gameP = ParsedGame <$ "Game " <*> decimal <* ": " <*> showingsP showingsP = showingP `sepBy` "; " showingP = cubeP `sepBy` ", " -cubeP = (flip Cube) <$> (decimal <* " ") <*> colourP +cubeP = (flip Cube) <$> decimal <* " " <*> colourP colourP = redP <|> greenP <|> blueP redP = Red <$ "red"