public int hamming() {
        int val = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                int index = i * N + j;
                if (index != blankIndex && tiles[index] != index + 1)
                    val++;
            }
        }
        return val;
    }