summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xprog/aoc/23/4/1.py21
-rw-r--r--prog/aoc/23/4/in.txt6
2 files changed, 27 insertions, 0 deletions
diff --git a/prog/aoc/23/4/1.py b/prog/aoc/23/4/1.py
new file mode 100755
index 0000000..2296fb9
--- /dev/null
+++ b/prog/aoc/23/4/1.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+s = 0
+c = []
+t = []
+try:
+ while True:
+ l = input()
+ w = set(l.split(":")[1].split(" | ")[0].split(" "))-set([""])
+ m = set(l.split(":")[1].split(" | ")[1].split(" "))-set([""])
+ c.append(len(m&w))
+ t.append(1)
+ if len(m&w) > 0:
+ s += 2**(len(w & m)-1)
+except:
+ print(s)
+ s2 = 0
+ for i in range(len(c)):
+ for j in range(c[i]):
+ t[1+i+j] += t[i]
+ s2 += t[i]
+ print(s2)
diff --git a/prog/aoc/23/4/in.txt b/prog/aoc/23/4/in.txt
new file mode 100644
index 0000000..9bdb874
--- /dev/null
+++ b/prog/aoc/23/4/in.txt
@@ -0,0 +1,6 @@
+Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
+Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
+Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
+Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
+Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
+Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11