0

I opened a question about game of fifteen before and took some suggestions, now I am trying to figure out why it will not exit. check50 says it waits for it to exit when seeing if it is winnable or not. Thank you!

Final working code:

bool won(void)
{
    // TODO
    int loop = 1;
    for (int i = 0; i <= d-1; i++)
    {
        for (int j = 0; j <= d-1; j++)
        {
                if (board[i][j] == loop)
                {
                    loop++;
                }
                else if (board[i][j] != board[d-1][d-1])
                {

                    return false;

                }

        }
    }


    return true;


}
1

What value will the last cell of the board have in the won state? Or, to ask in a different way, where is the blank tile supposed to be when the match is won?

| improve this answer | |
  • Thank you. I posted my final code for anyone's future reference. – R_C Oct 9 '17 at 17:56

You must log in to answer this question.

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