public Sudoku generateRandomCandidate(Random rng)
    {
        // Clone the template as the basis for this grid.
        Sudoku.Cell[][] rows = template.clone();
        for (int i = 0; i < rows.length; i++)
        {
            rows[i] = template[i].clone();
        }

        // Fill-in the non-fixed cells.
        for (int i = 0; i < rows.length; i++)
        {
            List<Integer> rowValues = nonFixedValues.get(i);
            Collections.shuffle(rowValues);
            int index = 0;
            for (int j = 0; j < rows[i].length; j++)
            {
                if (rows[i][j] == null)
                {
                    rows[i][j] = new Sudoku.Cell(rowValues.get(index), false);
                    ++index;
                }
            }
        }
        return new Sudoku(rows);
    }
public Sudoku generateRandomCandidate ( Random rng ) { Sudoku . Cell [ ] [ ] rows = template . clone ( ) ; for ( int i = 0 ; i < rows . length ; i ++ ) { rows [ i ] = template [ i ] . clone ( ) ; } for ( int i = 0 ; i < rows . length ; i ++ ) { List < Integer > rowValues = nonFixedValues . get ( i ) ; Collections . shuffle ( rowValues ) ; int index = 0 ; for ( int j = 0 ; j < rows [ i ] . length ; j ++ ) { if ( rows [ i ] [ j ] == null ) { rows [ i ] [ j ] = new Sudoku . Cell ( rowValues . get ( index ) , false ) ; ++ index ; } } } return new Sudoku ( rows ) ; }
{@inheritDoc}
The generated potential solution is guaranteed to have no
duplicates in any row but could have duplicates in a column or sub-grid.