From 99a7d62c30069a5ffe2210a72c7cf81e76a1f241 Mon Sep 17 00:00:00 2001 From: blenovo Date: Wed, 16 Jul 2025 18:55:48 +0200 Subject: summertime warmup session with 2020 event --- 2020/aoc2020-d06.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 2020/aoc2020-d06.py (limited to '2020/aoc2020-d06.py') 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); -- cgit v1.2.3