35 lines
784 B
Python
Executable file
35 lines
784 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import sys
|
|
|
|
|
|
def solve(input: list[str]) -> int:
|
|
def parse_turn(input: str) -> int:
|
|
direction = input[0]
|
|
clicks = int(input[1:])
|
|
return clicks * (1 if direction == "R" else -1)
|
|
|
|
def parse(input: list[str]) -> list[int]:
|
|
return [parse_turn(turn) for turn in input]
|
|
|
|
turns = parse(input)
|
|
start = 50
|
|
zeros = 0
|
|
for delta in turns:
|
|
if delta < 0:
|
|
to_zero = (start % 100) or 100
|
|
else:
|
|
to_zero = 100 - (start % 100)
|
|
start += delta
|
|
if abs(delta) >= to_zero:
|
|
zeros += (abs(delta) - to_zero) // 100 + 1
|
|
return zeros
|
|
|
|
|
|
def main() -> None:
|
|
input = sys.stdin.read().splitlines()
|
|
print(solve(input))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|