summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-12-01 19:53:43 +0000
committermhsn <mail@mhsn.net>2025-12-01 19:53:43 +0000
commitffb3260575dc2502faebef09127839b54d7eab44 (patch)
tree9f625533c82c572dfd79db9ac22dccebea12a6ee
parenta4df9089156c21c6d081da7edf6a51ec5bcd502e (diff)
downloadaoc-ffb3260575dc2502faebef09127839b54d7eab44.tar.gz
aoc-ffb3260575dc2502faebef09127839b54d7eab44.zip
25-01 python p1
-rwxr-xr-x2025/01/python.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/2025/01/python.py b/2025/01/python.py
new file mode 100755
index 0000000..2ba0bbd
--- /dev/null
+++ b/2025/01/python.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+from fileinput import input
+from itertools import accumulate
+
+lines = [line.strip() for line in input()]
+
+add = lambda p, m: (p + int(m[1:]) * ((m[0] == "R") * 2 - 1)) % 100
+
+silver = sum(p == 0 for p in accumulate(lines, add, initial=50))
+gold = 0
+
+print("silver:", silver)
+print("gold:", gold)