DEV Community

Discussion on: Advent of Code 2020 Solution Megathread - Day 6: Custom Customs

Collapse
 
willsmart profile image
willsmart

Python impl today. Prob not great python but works.

print(reduce(
    lambda acc, v: acc + len(
        set(v.replace('\n', ''))
    ),
    open("6.txt").read().split('\n\n'),
    0
))

print(reduce(
    lambda acc, v: acc + len(reduce(
        lambda acc, v: acc & v,
        map(
            lambda v: set(v), 
            v.split('\n')
        )
    )),
    open("6.txt").read().split('\n\n'),
    0
))
Enter fullscreen mode Exit fullscreen mode

Tomorrow will try something like prolog?!
Failing that, maybe Haskell.