blob: 475f8191d4aae0acbe705f376e8b447afeb06186 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
module Main where
import Data.Set (Set)
import qualified Data.Set as Set
parseLines :: [String] -> [String]
parseLines allLines = unwords first : next
where (first, rest) = break null allLines
next = if null rest then [] else parseLines (tail rest)
main :: IO ()
main = do
n <- parseLines . lines <$> readFile "input/06"
print $ sum $ map (Set.size . Set.fromList . filter (/= ' ')) n
print $ sum $ map (Set.size . foldl1 Set.intersection . map Set.fromList . words) n
|