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:
parent
f0f78fa25c
commit
56ca9d19c4
1 changed files with 29 additions and 0 deletions
29
2025-python/output/day_01.py
Normal file
29
2025-python/output/day_01.py
Normal 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
|
||||||
Loading…
Add table
Reference in a new issue