diff --git a/2020/README.md b/2020/README.md index 04f7713..241d239 100644 --- a/2020/README.md +++ b/2020/README.md @@ -11,3 +11,4 @@ https://adventofcode.com/2020/ | 3 | `**` | `**` | | | 4 | `**` | `**` | | | 5 | | `**` | | +| 6 | | `**` | | diff --git a/2020/day6/day6.hs b/2020/day6/day6.hs new file mode 100644 index 0000000..3d5993d --- /dev/null +++ b/2020/day6/day6.hs @@ -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)