aoc2020/6.py
2020-12-06 02:59:02 -06:00

15 lines
495 B
Python

with open("6.txt") as f:
data = f.read().split("\n\n")
def process(lines):
return len(set("".join(lines.split("\n"))))
print(sum(map(process, data)))
from functools import reduce
with open("6.txt") as f:
data = f.read().split("\n\n")
def process(lines):
lines = lines.strip()
letters = reduce(set.intersection, map(set, map(list, lines.split("\n"))))
print(repr(lines), letters)
return len(letters)
print(sum(map(process, data)))