first solution to day 6
This commit is contained in:
parent
08aa79acaa
commit
cc3975bdcd
26
06/06.py
Normal file
26
06/06.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
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()
|
2176
06/input.txt
Normal file
2176
06/input.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue