AoC24 - Some stone blinking
- 2 minutes read - 342 wordsWho said AoC25-11 should be complicated?
The Challenge
The ancient civilization on Pluto created stones that change every time you blink. Each stone follows specific transformation rules:
- A stone marked 0 becomes 1.
- A stone with an even number of digits splits into two stones, each half of the original number.
- Any other stone is replaced by a new one, with its number multiplied by 2024.
The stones remain in order, and their transformations continue with each blink. For example, the sequence [0, 1, 10, 99, 999] would change to [1, 2024, 1, 0, 9, 9, 2021976] after one blink.
Part 1: blink 25 times. Part 2: blink 75 times.
Full description available here.
Simple wouldn’t you say? While the first challenge required only 25 iterations, the answer was already of the order 105 processing an input of only 8 stones.
Reaching 75 iterations for the part 2 of the challenge easily tricked me into increasing the number of iterations in my original code.

After waiting over 10 minutes, I had barely reached 29 iterations—seeing others on Reddit who faced the same struggle was somewhat reassuring!
Being relatively new to Python while tackling this challenge, I opted for a simple yet effective approach. While many shared more intricate and likely faster solutions, using a straightforward Counter got the job done in just 14 ms.
import numpy as np
from functools import cache
from collections import Counter
def get_input():
with open('example.txt', 'r') as file:
stones = []
for line in file:
for char in line.split(' '):
stones.append(int(char))
return stones
def blink_at_stones(blinks, stones):
stones = Counter(stones)
for i in range(blinks):
print(f'Blink: {i}')
output = Counter()
for stone, occurences in stones.items():
if stone == 0:
#print('Found 0')
output[1] += occurences
#print('New array is' + str(stones))
continue
elif len(str(stone)) % 2 == 0:
#print(f'Found even nb {len(str(stone))}')
strSt = str(stone)
size = len(strSt)
output[int(strSt[:size//2])] += occurences
output[int(strSt[size//2:])] += occurences
continue
else:
#print('Found nothing!')
output[stone*2024] += occurences
#print('New array is' + str(stones))
continue
stones = output
return sum(stones.values())
if __name__ == '__main__':
print(blink_at_stones(75, get_input()))