Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Saw the Stick solution in Clear category for Saw the Stick by c135260
def checkio(number):
triangle = number
saw_list = []
for n in range(1,triangle):
saw_list.append(sum(range(n)))
if saw_list[-1] > triangle: break
for start in range(1,len(saw_list)):
res = []
triangle = number
for n in saw_list[start:-1]:
triangle -= n
res.append(n)
if triangle < 0 : break
if triangle == 0 : return res
return []
#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"
Oct. 21, 2016
Comments: