1 module Main(main) where
3 import Data.List (transpose, maximum, minimum, sort, group)
4 import Data.Tuple (swap)
8 text <- readFile "data/advent06.txt"
9 let message = lines text
13 part1 :: [String] -> IO ()
15 putStrLn $ map (snd . maximum . counts) $ transpose message
17 part2 :: [String] -> IO ()
19 putStrLn $ map (snd . minimum . counts) $ transpose message
21 counts :: (Eq a, Ord a) => [a] -> [(Int, a)]
22 counts = map (\g -> (length g, head g)) . group . sort