sudoku-rust
raw JSON → 1.0.7 verified Sat May 09 auth: no python
A high-performance Sudoku solver, generator, and validator backed by Rust, with a Python wrapper. Current version 1.0.7, release cadence is irregular. Supports Python >=3.8.
pip install sudoku-rust Common errors
error ModuleNotFoundError: No module named 'sudoku_rust' ↓
cause Improper import: 'sudoku' instead of 'sudoku_rust'.
fix
Use 'from sudoku_rust import Sudoku' (note the underscore).
error ImportError: cannot import name 'Sudoku' from 'sudoku_rust' ↓
cause May occur if the Rust extension failed to build (missing Rust toolchain).
fix
Install Rust or request a pre-built wheel for your platform.
error TypeError: generate_puzzle() missing 1 required positional argument: 'difficulty' ↓
cause Calling generate_puzzle() without arguments.
fix
Call generate_puzzle(difficulty) where difficulty is a float between 0 and 1.
Warnings
breaking The library is a wrapper around Rust code, and on some platforms (e.g., ARM Linux) the pre-built wheels may not be available, requiring Rust toolchain to build from source. ↓
fix Install Rust via rustup (https://rustup.rs) and then reinstall the package: 'pip install sudoku-rust --no-binary sudoku-rust'.
gotcha The puzzle representation uses 0 for empty cells, not '.' or other placeholders. ↓
fix Ensure input grids use integer 0 for blanks. Example: [[5,3,0,0,7,0,0,0,0], ...].
gotcha The generate_puzzle function returns a list of lists (nested list), not a NumPy array or flat list. ↓
fix Expect nested list format; if you need a different format, convert accordingly.
Imports
- Sudoku wrong
from sudoku import Sudokucorrectfrom sudoku_rust import Sudoku - generate_puzzle
from sudoku_rust import generate_puzzle - solve
from sudoku_rust import solve
Quickstart
from sudoku_rust import Sudoku, generate_puzzle, solve
# Generate a 9x9 puzzle with difficulty 0.5 (0=easy, 1=hard)
puzzle = generate_puzzle(0.5)
print("Puzzle:", puzzle)
# Create a Sudoku instance and solve
sudoku = Sudoku(puzzle)
solution = solve(sudoku)
print("Solution:", solution)