Part 1:
data = map(int, open("Day 11 input.txt", "r").read().strip().split())
for i in range(25):
new = []
for stone in data:
if stone == 0:
new.append(1)
elif len(str(stone))%2 == 0:
text = str(stone)
new.append(int(text[:len(text)/2]))
new.append(int(text[len(text)/2:]))
else:
new.append(stone * 2024)
data = new
#print data
print len(data)
Part 2
data = map(int, open("Day 11 input.txt", "r").read().strip().split())
cache = {}
def solve(stone, depth):
if (stone, depth) in cache: return cache[(stone, depth)]
if depth == 75:
return 1
if stone == 0:
result = solve(1, depth+1)
elif len(str(stone))%2 == 0:
text = str(stone)
result = solve(int(text[:len(text)/2]), depth+1)
result += solve(int(text[len(text)/2:]), depth+1)
else:
result = solve(stone*2024, depth+1)
cache[(stone, depth)] = result
return result
total = 0
for i in data:
total += solve(i, 0)
print total
Bruteforce part 1, DP part 2. Easy day.