The won function for fifteen is driving me crazy! Here's my implementation. I've run it through debug50 and it appears to work as expected. However, check50 only passes on a 4x4 board, but not a 3x3. Can someone help me spot the error in my code?
bool won(void)
{
int counter1 = 0;
int counterr = 0;
int counterc = 0;
for (int row = 0; row < d; row++)
{
for (int column = 0; column < d; column++)
{
counterc++;
if(counterc == d)
{
counterc = 0;
counterr++;
}
if (board[row][column] < board[counterr][counterc])
{
counter1++;
}
}
}
if (counter1 == d * d - 2) // The minus 1 is to account for the 0 at the end
return true;
else
return false;
}