aboutsummaryrefslogtreecommitdiff
path: root/execs/Day06.hs
diff options
context:
space:
mode:
Diffstat (limited to 'execs/Day06.hs')
-rw-r--r--execs/Day06.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/execs/Day06.hs b/execs/Day06.hs
new file mode 100644
index 0000000..c35fd21
--- /dev/null
+++ b/execs/Day06.hs
@@ -0,0 +1,19 @@
1
2module Main where
3
4import Data.Char (digitToInt)
5import Data.List (sort)
6import Data.Set (Set)
7import qualified Data.Set as Set
8import Control.Monad
9
10parseLines :: [String] -> [String]
11parseLines allLines = unwords first : next
12 where (first, rest) = break null allLines
13 next = if null rest then [] else parseLines (tail rest)
14
15main :: IO ()
16main = do
17 n <- parseLines . lines <$> readFile "input/06"
18 print $ sum $ map (Set.size . Set.fromList . filter (/= ' ')) n
19 print $ sum $ map (Set.size . foldl1 Set.intersection . map Set.fromList . words) n