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

26 lines
563 B
Python

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