Skip to content

Commit

Permalink
Add solution to 2024-12-11
Browse files Browse the repository at this point in the history
  • Loading branch information
fuglede committed Dec 11, 2024
1 parent 1e24f66 commit 9fb380f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 2024/day11/solutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from collections import Counter

with open("input") as f:
stones = Counter(map(int, f.read().split()))

for blinks in range(1, 76):
new_stones = Counter()
for n, num_stone in stones.items():
if n == 0:
new_stones[1] += num_stone
elif len(s := str(n)) % 2 == 0:
for m in int(s[: len(s) // 2]), int(s[len(s) // 2 :]):
new_stones[m] += num_stone
else:
new_stones[2024 * n] += num_stone
stones = new_stones
if blinks in (25, 75):
print(sum(new_stones.values()))

0 comments on commit 9fb380f

Please sign in to comment.