+ 3
How do you calculate number of inversions for a 8×8 puzzle?
The following tutorial shows how to do it but i don't understand it at all ,so if anyone can explain me ? Ty ! https://www.google.com/amp/s/www.geeksforgeeks.org/check-instance-8-puzzle-solvable/amp/ Also they talk about a=[[1, 8,2], [0, 4,3], [7, 6,5]] having 10 inversions but when i used their code to test it out , it came only 2!!.
1 ответ
0
I am highly guessing here...
I notice that “a” looks like it is meant to represent a grid, which could have multiple shufflings (IDK what an inversion is). however, if the code only worked with the upper layer (only the rows of the grid), it would end up with only 2 different ways to order the rows that did not basically come to the same thing when repeated.
What i mean is that no matter which way you mix 1 2 and 3, if you say the mix over and over you will find yourself either saying “1 2 3” or “3 2 1.”