Decompose integer into sum of squares by Seth Troisi slower

x=range(1,301)
r=[[]]
for i in x:
\x09a,j=5,0
\x09for k in x:
\x09\x09j+=1
\x09\x09if k*k>i:r+=[t];break
\x09\x09if k*k==i:t,a=[j],0
\x09\x09b=r[i-k*k];z=len(b)+1
\x09\x09if z<a:t,a=b+[j],z
\x09print "%d:"%(i)," ".join(map(str,r[i]))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page