aboutsummaryrefslogtreecommitdiff
path: root/2025/01/b.py
blob: ea32dc71222c2f34fda12490934735758df79605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import fileinput

p = 50
c = 0
with fileinput.input() as lines:
	for line in lines:
		oldp = p
		s = 1 if line[0] == "R" else -1
		p += s * int(line[1:])
		if p >= 100:
			d = p // 100
			c += d
			p -= d * 100
		elif p <= 0:
			d = -p // 100 + 1
			c += d if oldp != 0 else d-1
			p = (p + d * 100) % 100

print(c)

Generated with cgit - Back to sebastiano.tronto.net