2020 day6/haskell: add solution
This commit is contained in:
parent
a5a8d7b926
commit
c5409429e7
2 changed files with 10 additions and 0 deletions
|
@ -11,3 +11,4 @@ https://adventofcode.com/2020/
|
||||||
| 3 | `**` | `**` | |
|
| 3 | `**` | `**` | |
|
||||||
| 4 | `**` | `**` | |
|
| 4 | `**` | `**` | |
|
||||||
| 5 | | `**` | |
|
| 5 | | `**` | |
|
||||||
|
| 6 | | `**` | |
|
||||||
|
|
9
2020/day6/day6.hs
Normal file
9
2020/day6/day6.hs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import AoC
|
||||||
|
|
||||||
|
import qualified Data.Set as S
|
||||||
|
import Data.Set (Set)
|
||||||
|
|
||||||
|
main = runAoC ((fmap . fmap) S.fromList . splitOnEmptyLines) part1 part2
|
||||||
|
where part1 = countSetsFolded S.union
|
||||||
|
part2 = countSetsFolded S.intersection
|
||||||
|
countSetsFolded f = sum . map (S.size . foldr1 f)
|
Loading…
Reference in a new issue