summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-12-23 18:47:31 +0000
committermhsn <mail@mhsn.net>2025-12-23 19:14:55 +0000
commita9ab1f136aad824fb57f374f381e6b1986cdc42a (patch)
treee4a167782362dc56f78fa164da48d44c6b655563
parent61deb3f67b80fc1d9dd7946cb24f1f1dfbb9cedd (diff)
downloadaoc-a9ab1f136aad824fb57f374f381e6b1986cdc42a.tar.gz
aoc-a9ab1f136aad824fb57f374f381e6b1986cdc42a.zip
25-07 python p1
-rwxr-xr-x2025/07/python.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/2025/07/python.py b/2025/07/python.py
new file mode 100755
index 0000000..48a8f2a
--- /dev/null
+++ b/2025/07/python.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+from fileinput import input
+from functools import partial, reduce
+
+lines = [line.strip() for line in input()]
+
+bs = {lines[0].index("S")}
+silver = 0
+
+
+def split(t: int, c: int) -> set[int]:
+ global silver
+ if lines[t][c] == "^":
+ silver += 1
+ return {c - 1, c + 1}
+ return {c}
+
+
+for t, _ in enumerate(lines):
+ bs = reduce(set.union, map(partial(split, t), bs))
+
+
+gold = 0
+
+print("silver:", silver)
+print("gold:", gold)