We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d0ad810 commit 680bb87Copy full SHA for 680bb87
2024/day11/solutions.py
@@ -0,0 +1,19 @@
1
+from collections import Counter
2
+
3
+with open("input") as f:
4
+ stones = Counter(map(int, f.read().split()))
5
6
+for blinks in range(1, 76):
7
+ new_stones = Counter()
8
+ for n, num_stone in stones.items():
9
+ mid, rem = divmod(len(str(n)), 2)
10
+ if n == 0:
11
+ new_stones[1] += num_stone
12
+ elif rem:
13
+ new_stones[2024 * n] += num_stone
14
+ else:
15
+ for m in divmod(n, 10**mid):
16
+ new_stones[m] += num_stone
17
+ stones = new_stones
18
+ if blinks in (25, 75):
19
+ print(sum(new_stones.values()))
0 commit comments