summaryrefslogtreecommitdiff
path: root/2020/aoc2020-d06.py
diff options
context:
space:
mode:
authorblenovo <bk@gmail.com>2025-07-16 18:55:48 +0200
committerblenovo <bk@gmail.com>2025-07-16 18:55:48 +0200
commit99a7d62c30069a5ffe2210a72c7cf81e76a1f241 (patch)
tree71c5c529b7f2fda9b5b5897a56a4ef3199400709 /2020/aoc2020-d06.py
parent15662865f0886209d871a7225bfc62cffd2e0783 (diff)
summertime warmup session with 2020 event
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);