A comprehensive, modular Rust library and application suite for solving advanced Sudoku puzzles of various sizes (3x3, 4x4, 5x5, and more) using multiple solving strategies, with WebAssembly (WASM) and terminal UI support.
Add the core library to your Rust project:
[dependencies]
sudoko = "0.3"
# For WebAssembly support
sudoko = { version = "0.3", features = ["wasm"] }
Install the terminal UI application:
cargo install sudoko-tui
For WebAssembly projects, use the core library with WASM features enabled.
- Multiple Grid Sizes: 4x4 (2x2), 9x9 (3x3), 16x16 (4x4), 25x25 (5x5), and more
---
This workspace consists of two main crates:
- Located in sudoko/
--features wasm
Sudoku
, SudokuSolver
, Cell
, Difficulty
, and utilitiesWasmSudoku
and WASM utilities (when wasm
feature is enabled)- Located in sudoko-tui/
---
- Rust 1.70+ with Cargo
cargo build
# Core library
cargo build -p sudoko
# Core library with WASM support
cargo build -p sudoko --features wasm
# Terminal UI
cargo build -p sudoko-tui
# Solve a puzzle
cargo run -p sudoko --bin sudoko-cli -- solve "530070000600195000..." 9
# Generate a puzzle
cargo run -p sudoko --bin sudoko-cli -- generate 9 hard
# Get help
cargo run -p sudoko --bin sudoko-cli -- --help
cargo run -p sudoko-tui
Use the provided build-wasm.sh
script to build for web, node, and bundler targets:
./build-wasm.sh
See web-example/
for a browser demo.
---
use sudoko::{Sudoku, SudokuSolver, Difficulty};
// Create a new puzzle
let mut puzzle = Sudoku::new(9);
// Load from string
let puzzle = Sudoku::from_string("530070000...", 9)?;
// Solve the puzzle
let mut solver = SudokuSolver::new();
let solution = solver.solve(puzzle)?;
// Generate a new puzzle
let puzzle = solver.generate_puzzle(9, Difficulty::Hard)?;
import { WasmSudoku } from './pkg/sudoko.js';
// Create a new puzzle
const sudoku = new WasmSudoku(9);
// Load an example puzzle
const example = create_example_puzzle();
// Solve it
example.solve();
// Render as text
console.log(example.render_text());
---
1. Unified Codebase: Core logic and WASM interface are in one crate, reducing duplication 2. Optional Features: WASM support is feature-gated, keeping the core library lightweight 3. Reusability: The core library can be used in any Rust project with or without WASM 4. Simple UIs: TUI uses simple text rendering with no heavy dependencies 5. Clean API: Well-defined public interfaces for all functionality
- All crates use only the public API from the core library, ensuring clean boundaries and maintainable code.
MIT