summaryrefslogtreecommitdiff
path: root/2025/03
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-12-03 08:52:25 +0000
committermhsn <mail@mhsn.net>2025-12-03 08:52:25 +0000
commit11bfa80024879163a053e4e998482cdb40db562c (patch)
tree1b2a437bde3f0a24f0898d538d73928d73a09a34 /2025/03
parent217524b72271de38e5358f75bf9ce7c45322f861 (diff)
downloadaoc-11bfa80024879163a053e4e998482cdb40db562c.tar.gz
aoc-11bfa80024879163a053e4e998482cdb40db562c.zip
25-03 python p1
Diffstat (limited to '2025/03')
-rwxr-xr-x2025/03/python.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/2025/03/python.py b/2025/03/python.py
new file mode 100755
index 0000000..4c16c6d
--- /dev/null
+++ b/2025/03/python.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+from fileinput import input
+
+lines = [[int(b) for b in line.strip()] for line in input()]
+
+
+def joltage(bs: list[int]):
+ d2 = max(bs[:-1])
+ return max(d2 * 10 + max(bs[idx + 1 :]) for idx, b in enumerate(bs[:-1]) if b == d2)
+
+
+silver = sum(map(joltage, lines))
+gold = 0
+
+print("silver:", silver)
+print("gold:", gold)