summaryrefslogtreecommitdiff
path: root/2020/aoc2020-d06.py
diff options
context:
space:
mode:
Diffstat (limited to '2020/aoc2020-d06.py')
-rw-r--r--2020/aoc2020-d06.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/2020/aoc2020-d06.py b/2020/aoc2020-d06.py
new file mode 100644
index 0000000..8f0df5c
--- /dev/null
+++ b/2020/aoc2020-d06.py
@@ -0,0 +1,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);