Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(n**.5) in 9 lines solution in Speedy category for Saw the Stick by DiZ
def checkio(n):
s, tn, idx = 0, [0], {}
while tn[-1] < n:
idx[s] = len(tn)
tn.append(tn[-1] + idx[s])
s += tn[-1]
if s - n in idx:
return tn[idx[s - n]:]
return []
May 12, 2015
Comments: