I am trying to figure out if there is a solution to the below matrix. Source Matrix:

| 1 2 |
| 3 4 |
| 5 6 |
| 7 X |

'X' is a vacant position, and you can move you numbers around 'X'.

Can you arrange the numbers in such a way that it becomes a continuous sequence:

| 1 2 |
| 4 3 |
| 5 6 |
| X 7 |

If yes, then how??

有帮助吗?

解决方案 2

It is not possible. The parity of "X-less snake permutation" preserves for every move. Source matrix corresponds to snake permutation 124356x7 = 1243567 - odd. Destination matrix corresponds to snake permutation 1234567x = 1234567 - even.

其他提示

This puzzle is a variant of the Fifteen Puzzle. The idea is to compute the parity of the permutation of the numbers and the X plus the taxicab distance of the X (relative to the start position) and notice that this is invariant under every move. In your case the permutation is even and the taxicab distance odd thus the overall parity is odd. It follows that your instance of the puzzle is unsolvable.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top