# 3x3 Image puzzle solving algorithm



## majklcze2 (Jan 6, 2012)

Hello, i want to make software wich will solve classic 3x3 image puzzle in fastest possible way. What algorithm should i use? Is there somebody who can help me?


----------



## Carson (Jan 6, 2012)

Are you referring to the 3x3x3 cube with images on each side? Will this software be specific to only one cube, or will it be meant to work with any 3x3x3 logo cube? How do you intend to feed the cube state into the software... manually, webcam? When you say "fastest possible way," do you mean that they software will provide the solution in the least amount of time, or that the solutions is as short as possible so that a human may perform the solution as quickly as possible? Sorry for all of the questions, just trying to get a feel for what you intend to do.

It would probably make it easier to provide answers if you let everyone know how much knowledge you have of the cube already. I see that you are new to the forums... can you already solve a cube? If so, what method do you use and how long does it take. There are a lot of speedsolving specific terms and concepts, just wondering if you are aware of them already.


----------



## majklcze2 (Jan 7, 2012)

Thanks for fast reply. I mean classic 3x3 image puzzle, not cube. It same as sliding puzzle, but you can directly move parts everyvhere you want (without sliding). I just need help with some algorithm to try every possible combinations in 3x3 grid (Or some faster algorithm). Test all possible combinations under 30secs in 3x3 grid will be enough for me. I cant count how many combinations are there. It is for javascript game, there is automatic test if the puzzle is completed, so i just need to randomly move parts and test every possible combination in very short time.


----------



## Stefan (Jan 7, 2012)

Like a jigsaw puzzle? Sounds like the optimal solution is nine moves, given that you just simply move each of the nine pieces to its correct spot. I don't understand your problem. Maybe you should show us the game.


----------



## majklcze2 (Jan 7, 2012)

Yes, but every puzzle is generated randomly, and i need algorithmize it to make program wich will solve every puzzle very fast. So im thinking about moving pieces to try every possible combination. (How many combinations are there in 3x3 grid?)

Its similar to this game http://users.forthnet.gr/ath/abyss/games/impuzl1.htm but without one empty box (there are 9 pieces) and i can drag-and-drop the pieces directly.


----------



## Owen (Jan 7, 2012)

9! methinks.


----------



## mr. giggums (Jan 7, 2012)

Owen said:


> 9! methinks.


 
9!/2 because of parity.
So 181440 in total.


----------



## Stefan (Jan 7, 2012)

majklcze2 said:


> im thinking about moving pieces to try every possible combination.



Why would you do that? Just put every piece directly where it belongs. Done.
I still believe you should show us the actual game, because your posts don't make much sense.



mr. giggums said:


> 9!/2 because of parity.


 
Parity?


----------

