graveyard/aoc2020/6.py
2022-05-09 11:58:15 -05: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)))