aoc/2020/06/06_refactored.py
2020-12-10 17:11:17 -06:00

21 lines
499 B
Python

def read_file():
with open("input.txt","r") as f:
return f.read().split('\n\n')
def part1(groups):
"""Anyone"""
groupsets = [set(list(group.replace('\n',''))) for group in groups]
return sum(map(len, groupsets))
def part2(groups):
"""Everyone"""
allset = [set.intersection(*map(set, map(list,group.split('\n')))) for group in groups]
return sum(map(len,allset))
def main():
groups = read_file()
print(f'{part1(groups)=}')
print(f'{part2(groups)=}')
if __name__ == "__main__":
main()