0
$\begingroup$

We are given two matrices $R^{N \times N}$, each containing unique integers from $0$ to $N^2 - 1$ (except $0$, it does not need to be unique). The $0$ in the matrices will be called $blank$. The task is to determine a sequence of moves (not necessarily optimal) that transforms the configuration of the first matrix into that of the second. Moves consist of sliding a (orthogonally adjacent) tile into the $blank$ square.

This problem is a variant of the Sliding Puzzle, which typically involves a single $blank$ tile. It is known that a configuration is solvable iff the invariant (parity invariant) is the same in both matrices: the parity of the permutation of the numbered tiles combined with the parity of the blank’s Manhattan distance from its goal position.

For the one-$blank$ case, a constructive algorithm exists that can transform one state into another using at most $O(N^3)$ moves. Briefly: solve the board layer-by-layer (peel off outer rows/columns), place each tile into its goal using local cyclic move patterns that shift the tile one step at a time without disturbing already-fixed tiles, and repeat until only a $2\times2$ region remains. Each tile requires $O(N)$ local steps and there are $O(N^2)$ tiles, giving the $O(N^3)$ bound.

When the puzzle contains two or more $blanks$ the situation changes significantly: it has been proven that the state graph with two $blanks$ is connected, so any configuration can be reached from any other (see “Books, Hallways, and Social Butterflies: A Note on Sliding Block Puzzles”). The remaining challenge is to produce a practical (preferably $O(N^3)$), constructive algorithm that outputs an explicit sequence of moves in the multi-$blank$ setting. Can someone lend a helpful hand?

$\endgroup$
3
  • $\begingroup$ Quick thought that might lead to a solution. Fill in all but one of the blanks with the missing positive numbers so that the problem is solvable. Then solve it and erase the added numbers. (This will probably not leave the blanks in their original locations.) $\endgroup$ Commented Nov 1 at 19:39
  • $\begingroup$ Article “Books, Hallways, and Social Butterflies: A Note on Sliding Block Puzzles” can be found here $\endgroup$ Commented Nov 2 at 7:33
  • $\begingroup$ Besides, this article mentions similar work by Kornhauser et al. ; references can be found here and here. $\endgroup$ Commented Nov 2 at 7:47

1 Answer 1

0
$\begingroup$

Reduction 1: If there are $k > 2$ holes, fill all but two of them randomly with spare tiles, labeled with the numbers of $k-2$ of the target open-spaces, and you've reduced to the 2-open-spaces problem.

Reduction 2, for solving the two-hole puzzle: Reduce to showing that (*) any arrangement of the numbers with 2 missing can be shuffled to the "standard" (counting up from 1, reading left to right, top to bottom) in cubic time. Then you can solve the general problem of going from state P to state Q by moving $P$ to the "standard" position, and then moving the standard position to Q (by reversing the steps you'd use to get Q to the standard position).

To solve (*)

a. In linear time, move the two blanks (whose goal locations are $s$ and $t$) to locations 1 and 2.

b. Place a spare tile in square 1 and label it $s$; then determine whether the resulting 1-open-tile problem is solvable.

b1. If so, solve that problem and then remove that extra tile. Done!

b2. If not, then it WOULD be solvable if there were two adjacent pieces transposed on the rest of the board. So in the upper left block, do the following, after removing that spare tile. ("b" denotes a blank.)

bb xy xb by xb yb bx yb yx bb bx yb bb yx 

Now you've transposed the tiles $x$ and $y$. Put the spare tile, labeled $s$, back into the open space at position 1. You're now in a solvable state, so solve it, and remove the spare tile when you're finished.

Done!

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.