I will periodically post coding challenges to be solved with LiveCode.

Solving problems is a great way to improve your coding skills.

Vote for the best answer.

please paste **plain text** only.

please add **[code]** at the beginning of your code, and **[/code]** at the end to facilitate syntax colorizing.

if you see that **‘AndyP edited….’** your answer, this will be only for formatting.. I will **not** be changing your answer.

You have a 4×4 grid containing pieces numbered 1 to 16, of which you choose the order. To move the pieces you swap the positions of 2 pieces. Tiles must be swapped with adjacent tiles. The goal to to solve the puzzle in as few moves as possible, showing all steps. The steps are which 2 pieces swap positions for each move. Pieces could be referred to by their position or their number.

The starting layout for the grid is:

10 15 9 1

14 8 13 6

2 16 7 11

3 12 5 4

And the resolved grid output is:

1 2 3 4

5 6 7 8

9 10 11 1213 14 15 16