0

Could anyone help to have a look at my code? I ran check50 and it works for 3x3 but 4x4. However, when I checked manually with 4x4, it works.

Here is my code (won):

bool won(void)
{
int win_board = 1;
for(int i = 0; i < d; i++)
{
    for(int j = 0; j < d && win_board < d*d; j++)
    {
        if(board[i][j] != win_board)
        {
            return false;
        }
        win_board++;
    }
}
return true;

}

Check50 result: :) 3x3 board: make sure game is winnable :( 4x4 board: make sure game is winnable did not find output "1-2-3-4|5-6-7-8..."

I look further at the result of 4x4, it shows: "checking for output "1-2-3-4|5-6-7-8|9-10-11-12|13-14-15-0"... "

0

Trying to help, the only thing that occurs to me is that check50 does not like the last tile, which seems to be worth zero, I would simply check the tiles up to the value d *d - 1, for this we can put a small condition additional

if ( win_board == d*d-1) 
     return true;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .