is Solvable
fun isSolvable(puzzleState: ArrayList<Int>, blankTileMarker: Int): Boolean
Content copied to clipboard
Checks if the shuffled puzzle grid is solvable.
A puzzle grid is solvable if and only if the number of inversions in the puzzle state is even.
Return
true
if the shuffled puzzle grid is solvable; false
, otherwise.
Parameters
puzzleState
Current puzzle state (flattened into one dimension, following row-major order).
blankTileMarker
Indicator that the tile is blank.