A fast and efficient Sudoku solver built in Rust using recursive backtracking. It solves standard 9x9 grids while enforcing all Sudoku rules, showcasing Rust’s strengths in safety, speed, and clean algorithmic design.
The solver accepts a Sudoku puzzle as a string of 81 characters, using . or 0 for empty cells. Here's an example:
[..3.2.6.. 9..3.5..1 ..18.64.. ..81.29.. 7.......8 ..67.82.. ..26.95.. 8..2.3..9 ..5.1.3..]
🚀 Getting Started 🔧 Requirements
- Rust (latest stable version) 🛠️ Build & Run
cd sudoku-solver-rust cargo run
You can modify the puzzle input in src/main.rs.
🧠 How It Works
- Parses the input string into a 9x9 grid
- Finds the next empty cell
- Tries digits 1–9, checking for validity
- Recursively attempts to solve the puzzle
- Backtracks if a dead end is reached
✅ Example Output Given the input above, the solver will produce:
4 8 3 | 9 2 1 | 6 5 7 9 6 7 | 3 4 5 | 8 2 1 2 5 1 | 8 7 6 | 4 9 3 ------+-------+------ 5 4 8 | 1 3 2 | 9 7 6 7 2 9 | 5 6 4 | 1 3 8 1 3 6 | 7 9 8 | 2 4 5 ------+-------+------ 3 7 2 | 6 8 9 | 5 1 4 8 1 4 | 2 5 3 | 7 6 9 6 9 5 | 4 1 7 | 3 8 2
Let me know if you'd like to add syntax highlighting, a logo, or even a puzzle visualizer in the terminal!