Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Iterative :( solution in Creative category for Feed Pigeons by ale1ster
from itertools import takewhile,count
def checkio(number):
el = list(takewhile(lambda el: (el[0] <= number),
((i*(i+1)*(i+2)//6, i*(i+1)//2) for i in count(1))))[-1]
return (number - el[0]) if (number > sum(el)) else (el[1])
#These "asserts" using only for self-checking and not necessary for auto-testing
May 14, 2014
Comments: