Decompose integer into sum of squares by Seth Troisi

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

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

download

return to the top page