# Won()- Pset 3- Game of Fifteen

I'm having trouble seeing where my logic is going wrong with my won() function for Game of Fifteen (Pset 3).

For example looking at my for loop, let's say d=4, i = 2, j = 1. Then board[i][j] = board = 10, which is equal to the expression ((d*i)+(j+1)) = ((4*2) + (1+1) = 10. Therefore, 'false' is NOT returned for the first "if" statement, which is correct since 10 is indeed the entry for row 1, column 2. I've went through other i,j values as well, and everything seems to work out, so I have no idea where my program is going wrong.

"Check50" gives me the following error message: :( 3x3 board: make sure game is winnable timed out while waiting for program to exit :( 4x4 board: make sure game is winnable timed out while waiting for program to exit

Any suggestions on what I could be doing wrong?

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