Cs50 won function

Cs50 won function
0

#1

check50 keeps timing out on make sure game is winnable 4x4 grid. So I was wondering if there was something wrong with my won function posted below:

bool won(void)
{
    int num=1;
    for (int i=0; i<d; i++) {
        for (int j=0; j<d; j++) {
            if (i==d-1 && j==d-2 && board[i][j]==num) {
                num=0;
            } else if (i==d-1 && j==d-1 && board[i][j]==num) {
                return true;
            } else if (board[i][j]==num) {
               num++;
            } else {
                return false;
            }
        }
    }
return false;
}

#2

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard.