Wrong count for my inversions function
It is supposed to be 10 inversion count but I am getting 13
What am I screwing up or missing something ?
3 Replies
What do you mean by inversion?
it is for a puzzle problem
Now find the number of inversion, by counting tiles precedes the another tile with lower number. In our case, 1,2,3,4,5,6,7 is having 0 inversions, and 8 is having 1 inversion as it's preceding the number 7. Total number of inversion is 1 (odd number) so the puzzle is insolvable.trying to apply the same method
just counting, i get 12 13
but i'm lacking about four cups of coffee so idk
i'm not sure what you're trying to do really
1 precedes 0 : 1
8 precedes 2 0 4 3 7 6 5 : 7 (8)
2 precedes 0 : 1 (9)
0 precedes nothing
4 precedes 3 : 1 (10)
3 precedes nothing
7 precedes 6 5 : 2 (12)
6 precedes 5 : 1 (13)