graveyard/aoc2020/6.py

16 lines
495 B
Python
Raw Normal View History

2022-05-09 16:58:15 +00:00
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)))