Magic square by hallvabo

n=input()
x,y=n/2,0
a=[n*['']for _ in[0]*n]
for c in range(1,n*n+1):
\x09a[y][x]="%3d"%c
\x09u,v=(x+1)%n,(y+2)%n
\x09if a[v][u]:u,v=x,(y+1)%n
\x09x,y=u,v\x09
for r in a:print' '.join(r)

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

download

return top