0
0
Fork 0

Add code for 2020 day 6.

This commit is contained in:
Oliver-Akins 2020-12-06 21:44:06 -07:00
parent 54601c8efa
commit 90d1031207
3 changed files with 36 additions and 0 deletions

1
day_6/info.md Normal file
View file

@ -0,0 +1 @@
https://adventofcode.com/2020/day/6

16
day_6/part_1.py Normal file
View file

@ -0,0 +1,16 @@
with open("data") as f:
plane = f.read()
plane = plane.split("\n\n")
count = 0
for group in plane:
group_answers = []
for person in group.split("\n"):
for q in person:
if q not in group_answers:
group_answers.append(q)
count += len(group_answers)
print(count)

19
day_6/part_2.py Normal file
View 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)