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 2e175de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 2024/day11/solutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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():
mid, rem = divmod(len(s := str(n)), 2)
if n == 0:
new_stones[1] += num_stone
elif rem == 0:
for m in s[:mid], s[mid:]:
new_stones[int(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 2e175de

Please sign in to comment.