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 TovarischZhukov
def find(number, ln, cval=0):
retval=[]
for i, val in enumerate(ln):
c=number-val
if c==0 and (not cval or cval==val):
retval.append([val])
elif c>0 and (not cval or cval==val):
if ln[i+1:]:
f=find(c,ln[i+1:], ln[i+1])
for n in f:
retval.append([val]+n)
return retval
def checkio(number):
ln=[]
for i in range(1, number):
val=ln[i-2]+i if ln else i
if val>=number:
break
ln.append(val)
retval = find(number, ln[::-1])
return sorted(max(retval, key=len)) if retval else []
Dec. 24, 2015