Sudoku Generator
- class sudoku_smt_solvers.benchmarks.sudoku_generator.sudoku_generator.SudokuGenerator(size: int = 25, givens: int = 80, timeout: int = 5, difficulty: str = 'Medium', puzzles_dir: str = 'benchmarks/puzzles', solutions_dir: str = 'benchmarks/solutions')
Generates Sudoku puzzles and their solutions using Las Vegas algorithm.
This class handles the complete puzzle generation process: 1. Generates a complete valid solution using Las Vegas algorithm 2. Creates holes in the solution to create the actual puzzle 3. Saves both puzzle and solution with metadata
- Attributes:
size (int): Size of the Sudoku grid (e.g., 25 for 25x25) givens (int): Number of initial filled positions for Las Vegas timeout (int): Maximum generation attempt time in seconds difficulty (str): Target difficulty level for hole creation puzzles_dir (str): Directory for storing generated puzzles solutions_dir (str): Directory for storing solutions
- Example:
>>> generator = SudokuGenerator(size=9, difficulty="Hard") >>> puzzle, solution, puzzle_id = generator.generate()
- generate() Tuple[List[List[int]], List[List[int]], str]
Generate a complete Sudoku puzzle and solution pair.
Uses a two-step process: 1. Las Vegas algorithm generates a complete valid solution 2. Hole digger creates the puzzle by removing certain cells
- Returns:
- tuple: Contains:
List[List[int]]: The puzzle grid with holes
List[List[int]]: The complete solution grid
str: Unique identifier for the puzzle/solution pair
- Note:
The generated puzzle is guaranteed to have a unique solution