Magic square by tobiesque

n=input()
m=[]
exec"m+=[[0]*n];"*n
x=n/2
y=0
i=1
exec'm[y][x]="%3d"%i;y=(y+1,y+2)[i%n>0]%n;x=(x,x+1)[i%n>0]%n;i+=1;'*n*n
for l in m:print" ".join(l)

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

download

return top