aboutsummaryrefslogtreecommitdiff
path: root/2025/01/b.py
diff options
context:
space:
mode:
Diffstat (limited to '2025/01/b.py')
-rw-r--r--2025/01/b.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/2025/01/b.py b/2025/01/b.py
new file mode 100644
index 0000000..ea32dc7
--- /dev/null
+++ b/2025/01/b.py
@@ -0,0 +1,19 @@
1import fileinput
2
3p = 50
4c = 0
5with fileinput.input() as lines:
6 for line in lines:
7 oldp = p
8 s = 1 if line[0] == "R" else -1
9 p += s * int(line[1:])
10 if p >= 100:
11 d = p // 100
12 c += d
13 p -= d * 100
14 elif p <= 0:
15 d = -p // 100 + 1
16 c += d if oldp != 0 else d-1
17 p = (p + d * 100) % 100
18
19print(c)

Generated with cgit - Back to sebastiano.tronto.net