aoc/06/06_refactored.py

21 lines
499 B
Python
Raw Normal View History

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()