0

Can anyone help me point out the mistake I've made? The underscore just moved so wrong that I can't find the pattern.

enter image description here

1 Answer 1

0

First, please change board[i - 1][j] == 0 && i > 0 to i > 0 && board[i - 1][j] == 0 (same for the other lines), otherwise you risk segfaults, as you might dereference a pointer board[-1] before you realize it is not there.

Then, your algorithm does not stop after swapping, so maybe moving the empty tile up or left does not work, as it's instantly swapped back?

You must log in to answer this question.

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