aoc/2020/06/06.py

26 lines
563 B
Python
Raw Normal View History

2020-12-06 19:26:31 +00:00
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()