From 5eb58ad076f2cd435b11b140820da224b60b73d5 Mon Sep 17 00:00:00 2001 From: Aria Date: Mon, 2 Jan 2023 21:58:56 +0000 Subject: initial commit --- 2020/06b.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2020/06b.hs (limited to '2020/06b.hs') 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 -- cgit v1.2.3