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?
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
if cost < 4: return 1
for pile in range(1,int(math.sqrt(cost))+1))
for cost in count():
if nmax(cost)>=n: return cost