Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Saw the Stick by Moff
def checkio(stick):
n = 1
triangles = [1]
while triangles[-1] <= stick:
n += 1
triangles.append(n * (n + 1) // 2)
for i in range(n):
for j in range(n - i):
part = triangles[i:n-j]
if sum(part) == stick:
return part
return []
July 24, 2015