diff --git a/2015/day05/day05.hs b/2015/day05/day05.hs new file mode 100644 index 0000000..4a40391 --- /dev/null +++ b/2015/day05/day05.hs @@ -0,0 +1,18 @@ +import Aoc +import Text.Regex.PCRE + +part1 :: [String] -> Int +part1 = length . filter (\str -> hasVowels str && hasDouble str && not (hasForbidden str)) + where + hasVowels = (=~ "([aeiou].*){3}") + hasDouble = (=~ "(\\w)\\1") + hasForbidden = (=~ "(ab|cd|pq|xy)") + +part2 :: [String] -> Int +part2 = length . filter (\str -> hasPair str && hasBetween str) + where + hasPair = (=~ "(\\w\\w).*\\1") + hasBetween = (=~ "(\\w).\\1") + +main :: IO () +main = aocMain id part1 part2 \ No newline at end of file