Add code for 2020 day 6.
This commit is contained in:
parent
54601c8efa
commit
90d1031207
3 changed files with 36 additions and 0 deletions
19
day_6/part_2.py
Normal file
19
day_6/part_2.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
with open("data") as f:
|
||||
plane = f.read()
|
||||
|
||||
|
||||
plane = plane.split("\n\n")
|
||||
|
||||
count = 0
|
||||
for group in plane:
|
||||
group_size = len(group.split("\n"))
|
||||
group_answers = {}
|
||||
for person in group.split("\n"):
|
||||
for q in person:
|
||||
if q not in group_answers:
|
||||
group_answers[q] = 1
|
||||
else:
|
||||
group_answers[q] += 1
|
||||
count += len([1 for v in group_answers.values() if v == group_size])
|
||||
|
||||
print(count)
|
||||
Loading…
Add table
Add a link
Reference in a new issue