aboutsummaryrefslogtreecommitdiff
path: root/2020/06b.hs
diff options
context:
space:
mode:
Diffstat (limited to '2020/06b.hs')
-rw-r--r--2020/06b.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/2020/06b.hs b/2020/06b.hs
new file mode 100644
index 0000000..2cf3f03
--- /dev/null
+++ b/2020/06b.hs
@@ -0,0 +1,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 (); \ No newline at end of file