I can solve an easy puzzle but attempting a slightly harder one is impossible; what am I overlooking? Here is my solver method:
int solver (int x, int y)
{
int a, b, i, j;
for (a=1; a<10; a++)
{
if (checkEverything(x, y, a))
{
board[x][y] = a;
counter++;
if (counter == 81)
{
return true;
}
if (x == 9)
{
return true;
}
if (counter > 200 || counter < -10) {
return false;
}
for (i=0; i<9; i++)
{
for (j=0; j<9; j++)
{
if (board[i][j] == 0)
{
if (solver(i, j))
{
return true;
}
}
}
}
counter--;
}
}
board[x][y] = 0;
return false;
}
My checkEverything function checks to make sure that the given number is safe to be placed in the row, column, and 3x3 grid...I am very lost because it seems to be right to me but it is so slow. Thanks for any help!