Solve 2025 day 1 pt 1-2

Brute force, since I was to newly awake to figure out
the smart solution.
This commit is contained in:
Anders Englöf Ytterström 2025-12-01 08:04:10 +01:00
parent 5cc189cde0
commit 383dfa9e7a

View file

@ -0,0 +1,29 @@
def solve(data):
d = 50
p1 = 0
p2 = 0
for s in data.split():
sf0 = d == 0
m, T = (-1, 99) if s[0] == "L" else (1, 1)
for _ in range(int(s[1:])):
d = (d + m) % 100
if d == T:
if sf0:
sf0 = False
continue
p2 += 1
p1 += d == 0
return p1, p1 + p2
if __name__ == "__main__":
with open("./input/01.txt", "r") as f:
inp = f.read().strip()
p1, p2 = solve(inp)
print(p1)
print(p2)
assert p1 == 1195
assert p2 == 6770