Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
easy one solution in Clear category for Saw the Stick by 1-more
def checkio(number):
triangular = lambda x: x * (x + 1) // 2
# s = sum(triangular(i) for i in range(k, n))
k, n, s = 1, 2, 1
while s < number and k < n:
while s < number:
s, n = s + triangular(n), n + 1
while s > number:
s, k = s - triangular(k), k + 1
return [triangular(i) for i in range(k, n)] if s == number else []
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(64) == [15, 21, 28], "1st example"
assert checkio(371) == [36, 45, 55, 66, 78, 91], "1st example"
assert checkio(225) == [105, 120], "1st example"
assert checkio(882) == [], "1st example"
April 27, 2018