从已解决的数独谜题中移除每一行中的一个元素

Remove one element in each row from a solved Sudoku puzzle

我正在尝试创建一种方法,该方法将从我生成的已求解数独矩阵的每一行中删除一个随机元素。我怎样才能做到这一点?

已解决数独生成器:

public static void generate_Sud (int n, int [][] S){ // Generates Sudoku method 
    for (int r=0; r<=n-1; r++){
        int startNum = (int) (Math.sqrt(n) * (r % Math.sqrt(n)) + (r/Math.sqrt(n)));
        for (int c=0; c<=n-1; c++){
            S[r][c] = ((startNum + c) % n) + 1; 
        }
    }
}

Sudoku Matrix Generated

对于 3x3 数独:

for(int i = 0; i < 3; i++){
    int randomPosition = (int) Math.floor(Math.random() * 3)  //Random number between 0 and 2
    S[i][randomPosition] = -1; // -1 or whatever you use to represent blank
}