public static char[] getResult(char[] state, Action action) {
        for (int i=0; i<state.length; i++) {
            if (state[i] == Puzzle.BLANK) {
                char[] result = new char[state.length];
                int boardSize = (int) Math.sqrt(state.length);
                int iNew = i;

                if (action == Action.Left) iNew += 1;
                else if (action == Action.Right) iNew -= 1;
                else if (action == Action.Up) iNew += boardSize;
                else if (action == Action.Down) iNew -= boardSize;
                for (int j=0; j<state.length; j++) {
                    if (j == i) result[j] = state[iNew];
                    else if (j == iNew) result[j] = state[i];
                    else result[j] = state[j];
                }
                return result;
            }
        }
        return state;
    }