Tile Shift · The puzzle notebook

Tile Shift: why the distance total can rise on a good move.

Load a fixed board, watch its tile distance rise from four to six, and replay an eight-slide solution that restores the displaced tiles.

A move can put a tile farther from its target and still belong to a shortest solution. The reason is the gap: before a useful tile can slide, the empty square has to reach the right place. A distance count measures where the numbered tiles are, but it does not price every rearrangement needed to make their routes possible.

We will load one fixed Tile Shift board whose starting distance total is four. Its shortest solution takes eight slides, and the total rises on the first two moves of the route below. Tracking both numbers makes the detour visible.

Load the distance example

Use Practice this example in the side panel, or choose Load distance example below the live Tile Shift board. It replaces your current puzzle with this pattern and sets Moves to zero. The dot is the gap; rows and columns count from the top-left corner.

 1   2   3   4
 5   6   7   8
 9  14  11  12
13  15  10   ·

The target remains numbers 1–15 in row order, with the gap at bottom right. This example is made by eight legal slides from that goal, so it is solvable. Retry this board restores the same start and zero moves. New puzzle creates another random board. Refreshing a fixed practice entry reloads its example; it does not save your previous attempt.

What the distance total counts

For each numbered tile, count the row steps and column steps from its current square to its target square. Add those two counts, then sum over all numbered tiles. This is the Manhattan distance of the board. Do not include the gap. [1]

Only three numbered tiles are out of place at the start:

Starting numbered-tile distance
TileCurrentTargetDistance
10R4C3R3C21 row + 1 column = 2
14R3C2R4C21 row = 1
15R4C2R4C31 column = 1

Every other numbered tile contributes zero. The total is 2 + 1 + 1 = 4. The live game's Tile distance total should show 4, while Moves shows 0.

Four is a lower bound, not a four-move promise

One legal slide moves exactly one numbered tile by one horizontal or vertical square. Its distance to its target changes by exactly one: either up or down. The other numbered tiles do not move. A single slide can therefore reduce the total by at most one.

To turn a starting total of four into zero, at least four slides are necessary. That is a lower bound. It ignores whether the tiles can actually take those four favorable steps in that order and whether the gap must travel through already correct squares first.

Here the first move cannot reduce the total. The gap is at R4C4, so the only legal choices are 12 above it or 10 to its left. Tile 12 is already correct and moves one square away if selected. Tile 10 is two squares from its goal and becomes three squares away if it moves right. Either first choice raises the total from 4 to 5.

This already rules out a four-slide solution. A slide that raises the total needs an extra decrease later, adding two slides relative to an all-decreasing route. It does not, by itself, prove that six slides will be enough.

Replay an eight-slide solution

From the loaded starting board, select these tile numbers in order: 12, 11, 10, 15, 14, 10, 11, 12. Follow the numbers, not fixed button positions: the second selection of a number occurs after that tile has moved.

Moves completed and numbered-tile distance are different counts
MovesTile selectedSlideDistance total
0—Start4
112Down5
211Right6
310Up5
415Right4
514Down3
610Left2
711Left1
812Up0

The first two slides move previously correct tiles 12 and 11 out of place. They bring the gap beside tile 10. The following six slides then restore those tiles while arranging 10, 14, and 15. The upper two rows and the squares containing 9 and 13 stay unchanged throughout this route.

You make two distance-increasing slides and six distance-decreasing slides. Their net decrease is 6 − 2 = 4, while their total count is 6 + 2 = 8. This explains why the starting distance can be smaller than the number of moves, without suggesting that the temporary increase was a mistake.

Check why the gap is left out

Stop after the first two slides. The full board is now:

 1   2   3   4
 5   6   7   8
 9  14   ·  11
13  15  10  12

The numbered-tile total is six. The gap is two row-and-column steps from bottom right. Including it would produce eight, but the six remaining slides printed above finish this position. Eight would overestimate the required moves, so it would not be a valid lower bound here.

Sliding a tile also moves the gap. Counting both as independent travel costs can count the same action twice. The gap still matters when planning a route; leaving it out of this particular sum does not mean ignoring its position.

How the eight-move minimum was checked

The route shows that eight is sufficient. To check whether a shorter route exists, we also searched complete 4 × 4 boards in layers: start, then every new board one legal slide away, then every new board two slides away, and so on. Repeated boards were recorded only at their first, shortest depth.

All 414 distinct boards at depths 0–7 were checked, and none was the goal. A goal appeared at depth 8. This establishes eight as the minimum for this fixed start, even when moves anywhere on the full board are allowed. It is not a claim that every eight-slide route is useful or that a random board will have the same minimum.

Inspect the complete counts through seven slides
Distinct full boards first reached at each depth
Slides from startNew boards
01
12
24
310
424
554
6107
7212

The sum is 414. This layer search used the game's actual adjacent-slide rule, with no frozen rows or restricted working area.

A short self-check

Retry the example, select 12 and 11 again, then calculate the total yourself before looking at the displayed number. Which tiles now contribute, and can you predict all six remaining totals?

Check the contributions and the remaining sequence

Tiles 10, 14, and 15 still contribute 2, 1, and 1. Tile 11 adds 1, and tile 12 adds 1: total 6. The remaining sequence is 10, 15, 14, 10, 11, 12, with totals 5, 4, 3, 2, 1, 0 after each slide. The completed move counter reads 8 for the whole attempt.

Use the total as evidence, not a command

On another board, the distance total gives a minimum travel count for numbered tiles. It does not test solvability, identify the best next slide, or account for every required detour. A smaller number can be useful evidence when comparing positions, but a temporary increase can be part of a necessary plan.

Write down what a move lets the gap reach and which earlier work the rest of the sequence restores. The live game displays the total and counts your legal slides; it does not search for an optimum or rate your move. A tap on a nonadjacent tile changes neither count. The definition here assumes this site's 4 × 4 goal and ordinary adjacent slides.

Concept reference

[1] Princeton University, COS 226, “8-Puzzle Programming Assignment,” Spring 2015 archive: Manhattan distance and the exclusion of the blank. The general definition is applied here to our 4 × 4 goal. This lesson's worked board, eight-slide route, distance ledger, and complete layer counts were constructed and independently checked for H5 Free Fun.