[hs] Solve 2020_06
This commit is contained in:
parent
eb8a9795ed
commit
75fa851ff5
2 changed files with 27 additions and 0 deletions
25
hs/src/Aoc/Y2020/D06.hs
Normal file
25
hs/src/Aoc/Y2020/D06.hs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module Aoc.Y2020.D06
|
||||
( day
|
||||
) where
|
||||
|
||||
import qualified Data.Set as Set
|
||||
|
||||
import Aoc.Day
|
||||
import Aoc.Parse
|
||||
|
||||
type Group = [String]
|
||||
|
||||
parser :: Parser [Group]
|
||||
parser = sepBy (endBy1 (some lowerChar) newline) newline
|
||||
|
||||
solver :: [Group] -> IO ()
|
||||
solver groups = do
|
||||
putStrLn ">> Part 1"
|
||||
print $ sum $ map (Set.size . foldr1 Set.union . map Set.fromList) groups
|
||||
|
||||
putStrLn ""
|
||||
putStrLn ">> Part 2"
|
||||
print $ sum $ map (Set.size . foldr1 Set.intersection . map Set.fromList) groups
|
||||
|
||||
day :: Day
|
||||
day = dayParse "2020_06" parser solver
|
||||
Loading…
Add table
Add a link
Reference in a new issue