diff --git a/d11/run.py b/d11/run.py new file mode 100644 index 0000000..8391b49 --- /dev/null +++ b/d11/run.py @@ -0,0 +1,21 @@ +import sys +from math import log10 +from functools import cache + +@cache +def mutate(n:int, t:int) -> int: + if t == 0: + return 1 + if n == 0: + return mutate(1, t-1) + if (digits := int(log10(n))+1) & 1 == 0: + return count(divmod(n, 10**(digits//2)), t-1) + return mutate(n*2024, t-1) + +def count(stones: list[int], times: int) -> int: + return sum(mutate(stone, times) for stone in stones) + +stones = [int(n) for n in sys.stdin.read().strip().split(" ")] + +print(count(stones, 25)) +print(count(stones, 75))