getValidShuffledState

fun getValidShuffledState(puzzleState: ArrayList<Int>, goalPuzzleState: ArrayList<Int>, blankTileMarker: Int): StatePair

Returns the puzzle state and the position of the blank tile after a valid shuffling of the puzzle tiles.

A shuffling is considered valid if the resulting state is not equivalent to the goal state and if it is solvable (that is, it has an even number of inversions).

Return

Puzzle state (flattened into one dimension, following row-major order) and the position of the blank tile in the puzzle grid (zero-based, following row-major order) after shuffling.

Parameters

puzzleState

Puzzle state (flattened into one dimension, following row-major order).

goalPuzzleState

Goal state (flattened into one dimension, following row-major order).

blankTileMarker

Indicator that the tile is blank.