Skip to content

Commit

Permalink
construct FullState from candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
Nervonment committed Jun 8, 2024
1 parent 64dacf8 commit e680c99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 57 deletions.
24 changes: 24 additions & 0 deletions src/state/full_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ pub struct FullState {
)>,
}

impl FullState {
pub fn new(grid: Grid, candidates: [[[bool; 10]; 9]; 9]) -> Self {
let mut res = Self {
grid,
candidates: [[[true; 10]; 9]; 9],
candidate_cnt: [[9; 9]; 9],
cell_cnt_for_candidate_in_row: [[9; 10]; 9],
cell_cnt_for_candidate_in_col: [[9; 10]; 9],
cell_cnt_for_candidate_in_blk: [[9; 10]; 9],
history: vec![],
};
for r in 0..9 {
for c in 0..9 {
for num in 1..=9 {
if !candidates[r][c][num as usize] {
res.remove_candidate_of_cell(r, c, num)
}
}
}
}
res
}
}

impl From<Grid> for FullState {
fn from(puzzle: Grid) -> Self {
let mut res = Self {
Expand Down
57 changes: 0 additions & 57 deletions techniques.md

This file was deleted.

0 comments on commit e680c99

Please sign in to comment.