okay, i don't have a problem coding the game... that part would be easy. but the problem is to output the lease number of rotations needed to complete the game, so for example...
123 => 413
456 => 526
789 => 789
(rotation of the top left corner)
that's what it should look like after rotations.
now, i did some study, spent some time figuring the facts, and if i'm correct, the number of possible layouts of a 3*3 square is 9 factorial... which is uhmm... 362880. so even if i tried doing all the possible layouts, i wouldn't get the good result cause i have tho have the right sequence of operations... so, as i know nothing about the np-completeness.. (btw. is it?)i figured i better ask here as i really have no idea..
Jump to Post
it's about having a board with 9 numbers, 1-9 obviously. they are organized in a 3*3 matrix.
the solved problem looks like:
the problem is, you are given a scrambled matrix, and you have to fix it using 4 possible moves, rotate top left 2*2, top right, …
Jump to Post
It's called a depth-first search since you know the maximum number of moves.
Start with the unsolved starting point
3 5 2
8 7 1
4 6 9
Then generate the first possibilities with upper-left
saving this solution
Then rotate again,
All 11 Replies
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.