18 lines
504 B
Haskell
18 lines
504 B
Haskell
|
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
|