Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
DumbStraight solution in Clear category for Saw the Stick by bryukh
def triangular_numbers(max_numb):
"""
Generate the list with triangular numbers.
"""
a = 1
i = 1
res = [a]
while a < max_numb:
i += 1
res.append(a + i)
a += i
return res
def checkio(n):
"""
Simple, but not the fastest realisation and it very likes memory :)
"""
triangles = triangular_numbers(n)
lt = len(triangles)
for i in range(lt):
for j in range(i+1):
list_part = triangles[j:lt-i+j]
if sum(list_part) == n:
return list_part
return []
Feb. 8, 2014
Comments: