From 914147e8aaeb4d90d1637e6bde160e47c8567339 Mon Sep 17 00:00:00 2001 From: Emerentius Date: Sat, 2 Dec 2023 20:44:30 +0100 Subject: [PATCH] cut down generator interface with rngs to minimum --- src/board/sudoku.rs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/board/sudoku.rs b/src/board/sudoku.rs index 7aca067..bba8087 100644 --- a/src/board/sudoku.rs +++ b/src/board/sudoku.rs @@ -215,26 +215,6 @@ impl Sudoku { Sudoku::generate_with_symmetry_and_rng_from(sudoku, symmetry, &mut rand::thread_rng()) } - /// Generate a random, uniquely solvable sudoku with 180° rotational symmetry. - /// All random numbers are drawn from the given random number generator `rng`. - /// - /// The puzzles are minimal in that no cell can be removed without losing uniquess of the solution - /// whilst also upholding the symmetry. - /// Most puzzles generated by this are easy. - pub fn generate_with_rng(rng: &mut R) -> Self { - Sudoku::generate_with_symmetry_and_rng_from(Sudoku::generate_solved_with_rng(rng), Symmetry::HalfRotation, rng) - } - - /// Generate a random, uniquely solvable sudoku with the desired symmetry. - /// All random numbers are drawn from the given random number generator `rng`. - /// - /// The puzzles are minimal in that no cell can be removed without losing uniquess of the solution - /// whilst also upholding the symmetry. - /// Most puzzles generated by this are easy. - pub fn generate_with_symmetry_and_rng(symmetry: Symmetry, rng: &mut R) -> Self { - Sudoku::generate_with_symmetry_and_rng_from(Sudoku::generate_solved_with_rng(rng), symmetry, rng) - } - /// Generate a random, uniqely solvable sudoku /// that has the same solution as the given `sudoku` by removing the contents of some of its cells /// whilst upholding the `symmetry`. If the input sudoku is partially filled without the desired @@ -244,7 +224,11 @@ impl Sudoku { /// Most puzzles generated by this from solved sudokus are easy. /// /// If the source `sudoku` is invalid or has multiple solutions, it will be returned as is. - pub fn generate_with_symmetry_and_rng_from(mut sudoku: Sudoku, symmetry: Symmetry, rng: &mut R) -> Self { + pub fn generate_with_symmetry_and_rng_from( + mut sudoku: Sudoku, + symmetry: Symmetry, + rng: &mut R, + ) -> Self { // this function is following // the approach outlined here: https://stackoverflow.com/a/7280517 //