From 2329b38f531bc93de6e682e1af9e995072c6175c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 3 Dec 2025 13:06:51 +0100 Subject: 3b alternative solution suggested by Chiara --- 2025/03/b-alt.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 2025/03/b-alt.py (limited to '2025/03') 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 @@ +import fileinput + +def joltage(line, n): + if n == 0: + return 0 + + x = max(line[:len(line) - (n-1)]) + return x*10**(n-1) + joltage(line[line.index(x)+1:], n-1) + +with fileinput.input() as lines: + print(sum(joltage([int(x) for x in line[:-1]], 12) for line in lines)) -- cgit v1.3