# it is written on Python3. 6 Kings not attacking each other on a 6*6 chess table.
# you can test this on an online Python3 intrepreter.
rules,count,N=[],0,6
for i in range(N):
for j in range(-N,N):
if (i,j) not in ((1,1),(1,-1),(-1,1),(0,1),(0,0),(1,0),(0,-1),(-1,0),(-1,-1)):
rules.append((i,j))
print(rules)
def MarkCell(x,y,a,b):
global N
tempx,tempy=x+a,y+b
if x==tempx:
if tempy<=y:
return False
if tempx<0 or tempy<0:
return False
N1=N-1
if tempx>N1 or tempy>N1:
return False
for i in range(-1,2):
tempxi=tempx+i
for j in range(-1,2):
tempyj=tempy+j
if 0<=tempxi<N and 0<=tempyj<N:
if squares[tempxi][tempyj]==1:
return False
squares[tempx][tempy]=1
return True
def place(x,y,counter):
global count
global N
N2=N-2
for i in range(len(rules)-1):
a,b=rules[i]
if MarkCell(x,y,a,b):
if counter<N2:
place(x+a,y+b,counter+1)
else:
#print(squares)
count+=1
squares[x+a][y+b]=0
for i in range(N):
for j in range(N):
squares=[[0]*N for i in range(N)]
squares[i][j]=1
print(i,j)
place(i,j,0)
print("Yanıt=",count)