Solving the block puzzle
? ? ? ? ? ?
There may be four possible moves at each stage.
Some moves are not possible because of edges.
Make each possible move.
Then repeat for next step.
See if solved.

Each stage can be defined by an array of pieces.
eg 2,4,1,5,-,3
solved would be 1,2,3,4,5,-
and record how many stages to get there.
If you reach a stage, and that stage already exists, terminate.

Builds up a tree, each with four branches.
Pursue each level before moving deeper.
If solved, follow moves through parent branch.

Structure
level
parent
child 1
child 2
child 3
child 4

array of bits

coding this in javascript may be a challenge!

to do
    java

    set the starting values    
   
play the game
   
limit the solution, and set a value
    make solve play
    javascript
    put up the limited solution, after setting the value.
    replay backwards if too hard.

Good references
http://www.mathematische-basteleien.de/15puzzle.htm
http://www.permadi.com/java/puzzle8/
http://www-poleia.lip6.fr/~drogoul/projects/eco/npuzzle.html
stage 1
stage 2
stage 3
stage 4
stage 5
line line line line line
stage n
stage n
stage 6
line
stage n
line line
stage n
line
level 1
level 2
level 3
level 4