From 7e3af57f53552a062fac4c82bac96afb50d16c84 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 6 Dec 2020 03:14:14 -0600 Subject: [PATCH] 6 hs --- 6.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 6.hs diff --git a/6.hs b/6.hs new file mode 100644 index 0000000..edead42 --- /dev/null +++ b/6.hs @@ -0,0 +1,12 @@ +import Data.List +import Data.List.Split + +readlines :: FilePath -> IO [String] +readlines = fmap (splitOn "\n\n" . init) . readFile + +solution2 :: [[String]] -> Int +solution2 = sum . (map $ length . foldr1 intersect) + +main = do + input <- readlines "6.txt" + print (solution2 $ map (splitOn "\n") input)