So this has been a little frustrating. Even though the rest of the problem went well I cannot figure out where I went wrong. Here's the idea; set a counter called value that increments by every time to check for numbers 1, 2, 3, 4 ... in the correct order. There is an exception that, once reaching the bottom right corner (the blank) simply returns true. This is based one the assumption that once the for-loop gets to that point, everything else must be sorted. If the loop encounters a number on board [i][j] that is not equal to the value it should have, it returns false. When I test this with ./fifteen 3 < ~cs50/pset3/3x3.txt I get stuck in an infinite loop. All the other functions work properly. I have tested them all separately in a test file. Any pointers would be greatly appreciated!
bool won(void)
{
int value = 1;
for (int i = 0; i < d; i++){
for (int j = 0; j < d - 1; j++){
if (i == d-1 && j == d-1){
goto true_statement;
} else if (board[i][j] != value){
return false;
} else{
value++;
}
}
}
true_statement:
return true;
}