**127 bytes code**#Works for odd numbers only

n=3

j,A=n/2,[[0]*n for i in[0]*n]

i=c=0

while c<n*n:c=A[i][j]=c+1;i,j=[i+1,[n,i][i>0]-1][c%n>0],[j,[n,j][j>0]-1][c%n>0]

print A

**106 bytes code**#Works for odd numbers only

n=5

print [[(i+j-1+n/2)%n*n+(i+2*j-2)%n+1for j in range(n)]for i in range(n)]

## No comments:

## Post a Comment