Sliding down memory lane

James HeslipAPLLeave a Comment

I often got frustrated with puzzles as a child. Not in the sense that I couldn’t do them, but that I would never be satisfied until I could find a solution. It’s that kind of persistence which led me to propose this problem:


Sliding puzzles (Read about them on Wikipedia), like the one pictured above, are something I remember from my childhood; I could never really solve them, and if I ever did, it really was by brute force. This idea is to slide the pieces around using the free slot and get the pieces in numerical ascending order with the free slot in the bottom right.


I took the liberty of implementing this puzzle in APL using a grid object. You can “slide” pieces along by clicking on the number you wish to move. The number of moves are recorded as you go, and when you solve the puzzle you will be congratulated.

You can find this workspace here:

The problem I have is that I’m still not very good at these. The task that I’m posing is to create a program which can find the optimal solution: the number of moves required, and the moves actually required to implement this optimal solution.

Happy APLing!