diff --git a/day2/main.hs b/day2/main.hs index 6574942..3f91621 100755 --- a/day2/main.hs +++ b/day2/main.hs @@ -42,17 +42,13 @@ eitherToMaybe :: Either a b -> Maybe b eitherToMaybe (Right e) = Just e eitherToMaybe (Left _) = Nothing -match' :: Char -> Char -> Int -match' c1 c2 | c1 == c2 = 1 -match' _ _ = 0 - -- How many passwords are valid according to their policies? validatePassword1 :: Input -> Bool validatePassword1 (Input min' max' char' pass) = c >= min' && c <= max' where - c = foldl (\acc c' -> acc + match' char' c') 0 pass + c = (length . filter (== char')) pass -- How many passwords are valid according to the new interpretation of the -- policies?