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.
The algorithm
The algorithm consist of following steps:
- 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.
The steps
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.
Click on the image to see the animation
1.2 Move the 2nd piece to the top corner just close to the 1st piece
Click on the image to see the animation
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.).
Click on the image to see the animation
1.6 Position the last piece of the row just below it (right corner, 2nd position from the top)
Click on the image to see the animation
1.7 Move the before last piece to its correct place and the last piece just behind it
Click on the image to see the animation
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.).
Click on the image to see the animation
2.5 Move the last piece of the column just to the right of it (bottom corner, 2nd position from the left).
Click on the image to see the animation
2.6 Move the before last piece to its correct place and the last piece just behind it.
Click on the image to see the animation
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.
Click on the image to see the animation
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.
Have fun!
Pingback: Como Resolver o Jogo do 15 | VigHOME
Thanks for the solution, cheers !
I have a 10 X 10 done except the 81 and 91 are transposed< (81 is in column 1 row 10 and 91 is in col 1 row 9) and I am stuck. I don't see a solution to these in your solver. Do you have one?
Where did you play such a game? This should be an impossible situation
Please teach 5*5
It is the same as 4×4. You make a 5×5 become a 4×4 and a 4×4 become 3×3
I bow down to you oh my lord for having provided us with this great solution!
Koti Koti Pranamams!
Please make 5*5 slide puzzle. I always stuck in
Last step. My all slide solves but in last always 24 first
Before 23. Means 21 22 24 23.
You need to put the 21 with the sixteen
Prepare
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
xx xx xx xx
16 21 xx xx xx
Move 16 and 21
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 xx xx xx
21 xx xx xx xx