enter image description here

Everything is ok with the code, except of check50 which reports this one mistake, I assume problem is in my won function because everything else works. Can someone explain to me where mistake actually is? Thanks in advance

2 Answers 2


You return true too early. You only check whether all the tiles are in the correct order, but you don't check the position of the empty tile. A quick fix would be to replace

if (min == d*d)
    return true;
    return false;


return (min == d*d) && (board[d-1][d-1] == 0);

which additionally ensures that the last tile is the empty tile.

(I have some dislike for if (boolean expression) return true; else return false;, that's why I refactored that into a simple return statement, you could stay with that if, if you really want to, and just add the additional condition.)

  • Yes, thanks man..
    – faust91
    Commented Feb 7, 2017 at 17:24
  • I assumed that if first d*d-1 elements are in right order, game is won.My logic failed me i guess.. Thanks anyway, you helped a lot.
    – faust91
    Commented Feb 7, 2017 at 17:29

Your code is exiting (return 0) instead of still taking in input, it is not solving the board using the file.

You must log in to answer this question.

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