X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-20.git;a=blobdiff_plain;f=advent02%2Fsrc%2Fadvent02.hs;h=ce0eeb77245d679691debdde5f5c42379d3e47c3;hp=27886d05744f8c57507ef52f379f24b6e0b7f1fa;hb=68043122bb8c2cc485dfa18d26e547ad73730a2e;hpb=72c69da4bb83a1a18965411c7a52b3f9b3a18d2d diff --git a/advent02/src/advent02.hs b/advent02/src/advent02.hs index 27886d0..ce0eeb7 100644 --- a/advent02/src/advent02.hs +++ b/advent02/src/advent02.hs @@ -23,7 +23,6 @@ main = let policies = successfulParse text print $ part1 policies print $ part2 policies - -- print $ head $ part2 nums part1 = length . filter inRange where nCharsPresent p = length $ filter (== (character p)) (password p) @@ -56,9 +55,8 @@ passwordP = some alphaNumChar <* sc policiesP = many policyP policyP = Policy <$> integerP <* hyphenP <*> integerP <*> characterP <* colonP <*> passwordP --- policyP = (,,,) <$> integerP <* hyphenP <*> integerP <*> characterP <* colonP <*> passwordP --- successfulParse :: Text -> [Policy] +successfulParse :: Text -> [Policy] successfulParse input = case parse policiesP "input" input of Left _err -> [] -- TIO.putStr $ T.pack $ parseErrorPretty err