Polynomial Sequences part 2 by primo

while 1:
 a=raw_input().split();r=range(len(a));m=[[(i+1)**p for p in r]+[int(a[i])]for i in r]
 for j in r:s=m[j];m=[map(lambda a,b:a-b*(i[j]-(i==s))/s[j],i,s)for i in m]
 while~j:
\x09c=m[j][-1]
\x09if c:print('%+d'%c)[s>c>0:c*c+(j<1)]+('x^%d'%j)[:j*j],;s=0
\x09j-=1
 print

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

download

return top