summaryrefslogtreecommitdiff
path: root/2020/aoc2020-d06.py
blob: 8f0df5cdf0066504118708a055c3cfd14c3007d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#advent of code 2020
#day 06
PuzzleInput = open("06.in","r").read();
groups = PuzzleInput.split("\n\n");
p1 = 0;
p2 = 0;

for group in groups:
	anyone = group.replace("\n","");
	p1 += len(set(list(anyone)));
	everyone = group.split("\n");
	answers = [];
	for e in everyone:
		if len(e) == 0: continue; #some minor adjustment bc parsing
		answers.append(set(list(e)))
	total = answers[0]; #answers of the first guy (1st line)
	for a in answers[1:]:
		total = total.intersection(a); #shrink the set to duplicates only
	p2 += len(total);

print("part 1 =",p1);
print("part 2 =",p2);