# fifteen, won function does not seem to return if game one

My plan was simple. first check if the zero is in the right place. Then see if the element is correct using a formula and adding a counter so i only do it until i reach the field where the zero should be. Somehow when i run the test that should win the game.. it asks me for more input, so i think Liam not successfully returning true for some reason :(

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

}
return true;
}
``````

## 1 Answer

You have a typo. Either that, or you made an error in your formula.

``````        if (board[i][j]!=1+j+d*j)
``````
• i had a typo but it still does not work :( the formula should be (board[i][j]!=1+j+d*i) Jul 5 '16 at 17:36
• this is the error that i get, before that all checkmarks are green. :( 3x3.txt wins the 3x3 board \ expected an exit code of 0, not a prompt for input Jul 5 '16 at 17:38
• Not surprising. Have you worked out what happens when you get to the tile in the lower right corner? What value is it supposed to have? Jul 5 '16 at 17:51
• i thought at that point i expect a tile with value 0 , which obviously is not what the formula would give me. I tried to avoid that corner by the usage of the counter. So it stops comparing before it reaching that final tile. Jul 6 '16 at 2:40
• If your question is answered, could you please click on the check mark to accept and remove your question from the unanswered question pool? thanks. Jul 6 '16 at 10:19