blob: 2cf3f036b1a93a19720017bf12fae5a02442b4e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
module Day6B where
import Data.List (nub)
import Data.List.Split (splitOn)
import System.Environment (getArgs)
sharedElems :: [String] -> [Char]
sharedElems xs = filter (\x -> all (x `elem`) xs) (nub $ concat xs)
-- Usage: runghc --ghc-arg="-package split" 6b.hs inputs/day6
main :: IO ()
main = do
args <- getArgs;
content <- readFile $ head args;
print $ sum $ map (length . sharedElems . lines) $ splitOn "\n\n" content;
return ();
|