diff options
author | Akshay <[email protected]> | 2020-12-06 05:11:16 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-06 05:11:16 +0000 |
commit | 3b5efe46256a545f2e258003cf11c9c6ef6dcb7f (patch) | |
tree | 7e8df091c20d2bdb7c0a72ce8394e58c9aac5fcb /execs | |
parent | d41dca8b131d580eed2bcdc382bda9a634c57bf9 (diff) |
ad initial solution to day06
Diffstat (limited to 'execs')
-rw-r--r-- | execs/Day06.hs | 19 |
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 | |||
2 | module Main where | ||
3 | |||
4 | import Data.Char (digitToInt) | ||
5 | import Data.List (sort) | ||
6 | import Data.Set (Set) | ||
7 | import qualified Data.Set as Set | ||
8 | import Control.Monad | ||
9 | |||
10 | parseLines :: [String] -> [String] | ||
11 | parseLines allLines = unwords first : next | ||
12 | where (first, rest) = break null allLines | ||
13 | next = if null rest then [] else parseLines (tail rest) | ||
14 | |||
15 | main :: IO () | ||
16 | main = 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 | ||