aboutsummaryrefslogtreecommitdiff
path: root/2025
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-03 13:06:51 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-03 13:07:18 +0100
commit2329b38f531bc93de6e682e1af9e995072c6175c (patch)
tree26e1ef27514b8bafd86e05ac9a123b1266f8ab96 /2025
parent1dc404e7ee276f6a5798ec93d5ae47e08d180432 (diff)
downloadaoc-2329b38f531bc93de6e682e1af9e995072c6175c.tar.gz
aoc-2329b38f531bc93de6e682e1af9e995072c6175c.zip
3b alternative solution suggested by Chiara
Diffstat (limited to '2025')
-rw-r--r--2025/03/b-alt.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/2025/03/b-alt.py b/2025/03/b-alt.py
new file mode 100644
index 0000000..43e2695
--- /dev/null
+++ b/2025/03/b-alt.py
@@ -0,0 +1,11 @@
1import fileinput
2
3def joltage(line, n):
4 if n == 0:
5 return 0
6
7 x = max(line[:len(line) - (n-1)])
8 return x*10**(n-1) + joltage(line[line.index(x)+1:], n-1)
9
10with fileinput.input() as lines:
11 print(sum(joltage([int(x) for x in line[:-1]], 12) for line in lines))

Generated with cgit - Back to sebastiano.tronto.net