在研究著名的N Queens puzzle,我碰到this簡單,易於理解的C實現: #include<stdio.h>
#include<math.h>
int board[20],count;
int main()
{
int n,i,j;
void queen(int row,int n);
printf(" - N Queens Problem Using Backtra
這裏是我在Python中的代碼,撥打knightsTour(0,0,1,sol,xMove,yMove)應該返回True,但我得到False。我無法找到這個錯誤。 def safe(x,y,sol):
return x >= 0 and x < 8 and y >= 0 and y < 8 and sol[x][y] == -1
def knightsTour(x,y,move,so