adventofcode2024/day11/sol.py

22 lines
542 B
Python

def solve(file):
nums = file.read().split()
for i in range(25):
if len(nums) < 100:
print(i, nums)
new = []
for n in nums:
if n == '0':
new.append('1')
elif len(n)%2 == 0:
new.append(n[:len(n)//2])
new.append(n[len(n)//2:].lstrip('0') or '0')
else:
new.append(str(int(n)*2024))
nums = new
print(len(nums))
from io import StringIO
solve(StringIO("0 1 10 99 999"))
solve(open("input"))