Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
recursive lambda solution in Creative category for Sum of Distinct Cubes by roman.bratishchev
# Credits:
# veky for simplification https://py.checkio.org/mission/sum-of-distinct-cubes/publications/veky/python-3/reversedrangeminsuccceilcbrt/
# Phil15 for upper bound https://py.checkio.org/mission/sum-of-distinct-cubes/publications/Phil15/python-3/recursive-with-decreasing-upperbounds/
# Notes:
# 'floor_cbrt' approximation still fails on ultrabig numbers aka 1000**15
sum_of_cubes=lambda n, K=float('inf'), floor_cbrt=lambda n:(k:=1+int(n**(1/3)))-(k**3>n): next(
([k]+tail for k in range(min(floor_cbrt(n),K),0,-1) if (tail:=sum_of_cubes(n-k**3,k-1)) is not None),
None
) if n else []
Jan. 6, 2026