public static boolean isValidPermutation(final byte[] state) {
		final int numOfTiles = state.length, dim = (int) Math.sqrt(numOfTiles);
		int inversions = 0;
		for (int i = 0; i < numOfTiles; ++i) {
			final byte iTile = state[i];
			if (iTile != 0) {
				for (int j = i + 1; j < numOfTiles; ++j) {
					final byte jTile = state[j];
					if (jTile != 0 && jTile < iTile) {
						++inversions;
					}
				}
			} else {
				if ((dim & 0x1) == 0) {
					inversions += (1 + i / dim);
				}
			}
		}
		if ((inversions & 0x1) == 1)
			return false;
		return true;
	}