File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 11use crate :: { EMPTY , Sudoku } ;
2+ use rand:: prelude:: ThreadRng ;
23use rand:: seq:: SliceRandom ;
34
45impl Sudoku {
@@ -93,7 +94,7 @@ impl Sudoku {
9394 /// and finally removes cells while ensuring a unique solution.
9495 /// The `filled_cells` parameter specifies how many cells should remain filled.
9596 pub fn generate_diagonal_fill ( filled_cells : usize ) -> Option < Self > {
96- let mut rng = rand:: rng ( ) ;
97+ let mut rng: ThreadRng = rand:: rng ( ) ;
9798 let mut all_digits: Vec < u8 > = ( 1 ..=9 ) . collect ( ) ;
9899 let mut sudoku = Sudoku :: new ( ) ;
99100 // Fill the 3 diagonal boxes (top-left, middle, bottom-right)
@@ -110,7 +111,6 @@ impl Sudoku {
110111 // Get all filled cells that haven't been removed yet
111112 let mut available_cells: Vec < ( usize , usize ) > = ( 0 ..9 )
112113 . flat_map ( |row| ( 0 ..9 ) . map ( move |col| ( row, col) ) )
113- . filter ( |& ( row, col) | sudoku. board [ row] [ col] != EMPTY )
114114 . collect ( ) ;
115115 available_cells. shuffle ( & mut rng) ;
116116 available_cells. truncate ( 81 - filled_cells) ;
You can’t perform that action at this time.
0 commit comments