After seeing many people giving up while playing slide puzzles in the best free online puzzle site, I decided to write this fool proof fully illustrated guide to solve any slide puzzle (3×3, 4×4, 5×5, …).
I came to the solution while developing the website im-a-puzzle.com and observing that the A* like algorithms take too long to solve puzzles. The nice thing about the solution is that it is so simple that even an human being can execute it 🙂
Divide and conquer
The beauty of the solution proposed here is that it is applicable to any puzzle size: 3×3, 4×4, 5×5, etc. The trick is to solve the corners first so that a 5×5 puzzle becomes a 4×4 and then a 3×3. This technique is also known as divide and conquer, where a complex problem is broke down into sub-problems, until these become simple enough to be solved directly.
- Solve the top corner (step 1 below)
- Solve the left corner (step 2 below)
- Repeat steps 1 and 2 until the puzzle size is decreased to 3×3
- Solve the top corner only (step 1 below)
- Solve the remaining 3×2 puzzle (step 4 below)
To move a piece to any position the easiest way is to:
- Put the blank square at the target position
- Move your piece in the target direction by moving all the pieces one square forward
- Put the blank square ahead of your piece again by revolving the pieces around your target piece
- Repeat steps 2 and 3 until your piece reaches its target
You are going to find many animated examples of these steps in the guide below. As the algorithm consist of solving the corners one-by-one, once a corner is solved it is consider as “frozen” and you should no longer touch it. That means that when you are revolving the pieces around your target piece you should never breach the “frozen” area.
STEP 1 – Solve the upper corner
Position all the top pieces from left to right:
1.1 Move the 1st piece to the top left corner.
1.2 Move the 2nd piece to the top corner just close to the 1st piece
1.3 If required move the 3rd, 4th pieces and so on until there is only 2 missing (applicable for puzzles bigger than 4×4)
1.4 Make sure that the last piece of the row is not on the top row itself. If yes, move it out! (Anywhere far away from it)
1.5 Move the before last piece of the row to the top right corner (for a 3 columns puzzle, the 2nd piece, for a 4 columns puzzle the 3rd piece, etc.).
1.6 Position the last piece of the row just below it (right corner, 2nd position from the top)
1.7 Move the before last piece to its correct place and the last piece just behind it
If you are solving a 3×3 puzzle jump to step 4
STEP 2 – Solve the left corner
Position all the left pieces from top to bottom. Please note that the first piece is already be on its correct position:
2.1 Move the 2nd piece of the column just below the 1st piece
Click on the image to see the animation
2.2 If required move the 3rd, 4th pieces and so on until there is only 2 missing (applicable for puzzles bigger than 4×4)
2.3 Make sure that the last piece of the column is not on the left column itself. If yes, move it out! (Anywhere far away from it)
2.4 Move the before last piece of the column to the bottom left corner (for a 3 columns puzzle, the 4th piece, for a 4 columns puzzle the 9th piece, etc.).
2.5 Move the last piece of the column just to the right of it (bottom corner, 2nd position from the left).
2.6 Move the before last piece to its correct place and the last piece just behind it.
STEP 3 – Repeat steps 1 and 2
Consider the top and left corners as frozen (you are not allowed to touch these pieces anymore!). Go back to step 1 assuming that you are now solving a smaller puzzle. Examples:
- If you froze the top and left corners of a 4×4 puzzle, you will now have to solve a 3×3 puzzle.
- If you froze the top and left corners of a 5×5 puzzle, you will now have to solve a 4×4 puzzle.
- And so on…
If you are solving a 3×3 puzzle you will execute step 1 only and jump to step 4
STEP 4 – Solve the 3×2 puzzle
If you got here than there are only 5 pieces left to position (plus the blank piece). From here on, there is no all-in-one solution and you have to find the solution out yourself. But at the same time there are not many possible combinations.
You will notice that there are only 4 basic movements possible: turning the first square clockwise or counterclockwise or turning the second square clockwise or counterclockwise. You will have to find your way and use them over and over until the 3×2 puzzle is solved. The worst case scenario happens when the numbers are displayed in the opposite order or when they are in the right order but in the wrong row.
The good thing is that this amazing puzzle maker only generates solvable puzzles. You do not have to be afraid that your puzzle will not have a solution.
If you have any suggestions or comments to the current algorithm feel free to write them here below.