Run cargo fmt
This commit is contained in:
parent
1b91ec74ce
commit
978d3ab3f3
3 changed files with 22 additions and 13 deletions
|
@ -141,12 +141,11 @@ fn main() {
|
|||
"Number of threads to use when generating possible puzzles",
|
||||
);
|
||||
|
||||
ap.refer(&mut print_possibilities)
|
||||
.add_option(
|
||||
ap.refer(&mut print_possibilities).add_option(
|
||||
&["-p", "--possibilities"],
|
||||
argparse::StoreTrue,
|
||||
"Include each cell's possibilities in the output; applies only to PDF output"
|
||||
);
|
||||
"Include each cell's possibilities in the output; applies only to PDF output",
|
||||
);
|
||||
|
||||
ap.parse_args_or_exit();
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ fn main() {
|
|||
max_attempts,
|
||||
max_hints,
|
||||
&AtomicBool::new(false),
|
||||
debug
|
||||
debug,
|
||||
)
|
||||
} else {
|
||||
run_multi_threaded(
|
||||
|
@ -260,7 +259,7 @@ fn run_multi_threaded(
|
|||
thread_attempts,
|
||||
max_hints,
|
||||
should_stop,
|
||||
debug
|
||||
debug,
|
||||
);
|
||||
|
||||
let mut result_was_some = false;
|
||||
|
@ -313,7 +312,7 @@ fn get_puzzle_matching_conditions(
|
|||
max_attempts: i32,
|
||||
max_hints: i32,
|
||||
should_stop: &AtomicBool,
|
||||
debug: bool
|
||||
debug: bool,
|
||||
) -> (Option<(Grid, SolveStatistics, i32)>, i32) {
|
||||
let mut num_attempts = 0;
|
||||
|
||||
|
|
|
@ -219,11 +219,17 @@ fn generate_completed_grid(rng: &mut SmallRng) -> Grid {
|
|||
eprintln!("Wow! A puzzle with only 8 guesses have been found");
|
||||
return grid;
|
||||
}
|
||||
Uniqueness::NotUnique => {break grid;} // What we expect
|
||||
Uniqueness::NotUnique => {
|
||||
break grid;
|
||||
} // What we expect
|
||||
}
|
||||
}
|
||||
SolveStatus::Unfinished => {panic!("evaluate_grid_with_solve_controller should never return UNFINISHED if we are making guesses")}
|
||||
SolveStatus::Invalid => {continue;} // unlucky; try again
|
||||
SolveStatus::Unfinished => {
|
||||
panic!("evaluate_grid_with_solve_controller should never return UNFINISHED if we are making guesses")
|
||||
}
|
||||
SolveStatus::Invalid => {
|
||||
continue;
|
||||
} // unlucky; try again
|
||||
}
|
||||
};
|
||||
|
||||
|
|
10
src/pdf.rs
10
src/pdf.rs
|
@ -9,7 +9,11 @@ const GRID_DIMENSION: f64 = 190.0;
|
|||
|
||||
const A4: (Mm, Mm) = (Mm(215.0), Mm(279.0));
|
||||
|
||||
pub fn draw_grid(grid: &Grid, filename: &str, print_possibilities: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn draw_grid(
|
||||
grid: &Grid,
|
||||
filename: &str,
|
||||
print_possibilities: bool,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let (doc, page1, layer1) = PdfDocument::new("Sudoku Puzzle", A4.0, A4.1, "Layer 1");
|
||||
let layer = doc.get_page(page1).get_layer(layer1);
|
||||
|
||||
|
@ -45,12 +49,12 @@ pub fn draw_grid(grid: &Grid, filename: &str, print_possibilities: bool) -> Resu
|
|||
CellValue::Unknown(possibilities) => {
|
||||
if print_possibilities {
|
||||
for (_, possibility) in possibilities.iter().enumerate() {
|
||||
|
||||
let sub_row = (possibility - 1) / 3;
|
||||
let sub_column = (possibility - 1) % 3;
|
||||
// Need to adjust x & y
|
||||
let x = Mm(x.0 - 4.0 + (GRID_DIMENSION / 27.0) * (sub_column as f64));
|
||||
let y = Mm(y.0 - 9.5 + (GRID_DIMENSION / 27.0) * (3.0 - sub_row as f64));
|
||||
let y =
|
||||
Mm(y.0 - 9.5 + (GRID_DIMENSION / 27.0) * (3.0 - sub_row as f64));
|
||||
|
||||
let text = possibility.to_string();
|
||||
layer.use_text(text, possibility_font_size, x, y, &font);
|
||||
|
|
Loading…
Reference in a new issue