You are viewing a single comment's thread. Return to all comments →
And here's another solution. How it works is explained further down, see the entry of @kiwic.
''' How many stones (maximum) can you fit in for given cost? -> nmax(cost) Obviously every pile has to give this same cost, that is -> nmax(cost-1^2) + nmax(cost-2^2)+... ''' from functools import cache from itertools import count @cache def nmax(cost): if cost < 4: return 1 return sum(nmax(cost-pile**2) for pile in range(1,int(math.sqrt(cost))+1)) def towerBreakers(n): for cost in count(): if nmax(cost)>=n: return cost
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers - The Final Battle
You are viewing a single comment's thread. Return to all comments →
And here's another solution. How it works is explained further down, see the entry of @kiwic.