summaryrefslogtreecommitdiff
path: root/2025/01/python.py
blob: d5ff1fa76a2ffb5617a29d2128dc36ffbb05bcb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3

from fileinput import input
from itertools import accumulate


def fn(p: tuple[int, int], rot: str) -> tuple[int, int]:
    x = p[0] + int(rot[1:]) * (1 if rot[0] == "R" else -1)
    return x % 100, abs(x) // 100 + (p[0] and x <= 0)


p1, p2 = zip(*list(accumulate(input(), fn, initial=(50, 0))))

print(f"silver: {sum(not p for p in p1)}")
print(f"gold: {sum(p2)}")