MCPcopy Index your code
hub / github.com/Emerentius/sudoku

github.com/Emerentius/sudoku @v0.7.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.7.0 ↗ · + Follow
283 symbols 723 edges 28 files 87 documented · 31% updated 2y ago★ 974 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Sudoku

Crates.io Status Build Status

Utilities for classical 9x9 sudokus.

This library currently offers extremely fast sudoku solving, a basic sudoku generator and a prototype solver using human strategies. The fast solver is based on jczsolve which is currently and to the best knowledge of the author the world's fastest sudoku solver algorithm. A few modifications were made to improve the speed further. The strategy solver is capable of applying a few simple strategies, namely naked and hidden singles, locked candidates, naked and hidden subsets (Pairs, Triples, Quads) and basic fish (X-Wing, Swordfish, Jellyfish). An explanation of these strategies and more can be found at http://www.sudokuwiki.org/Strategy_Families.

A future goal is the extension and further optimization of the strategy solver, so that most sudokus can be graded, hinted and the solution path explained. With the ability to grade sudokus, puzzles of any desired desired difficulty can also be generated.

Example

use sudoku::Sudoku;

// Sudokus can be created from &str's in both block or line formats or directly from bytes.
// here, an example in line format
let sudoku_line = "...2...633....54.1..1..398........9....538....3........263..5..5.37....847...1...";

let sudoku = Sudoku::from_str_line(sudoku_line).unwrap();

// Solve, print or convert the sudoku to another format
if let Some(solution) = sudoku.solve_unique() {
    // print the solution in line format
    println!("{}", solution);

    // or return it as a byte array
    let cell_contents: [u8; 81] = solution.to_bytes();
}

Extension points exported contracts — how you extend this code

CellAt (Interface)
Trait for cell groupings that have all of their cells enumerated [5 implementers]
src/board/positions.rs
SetElement (Interface)
(no doc)
src/bitset.rs
IntoHouse (Interface)
(no doc) [1 implementers]
src/board/positions.rs

Core symbols most depended-on inside this repo

len
called by 45
src/strategy/deduction.rs
iter
called by 30
src/board/sudoku.rs
is_empty
called by 20
src/bitset.rs
into_iter
called by 15
src/bitset.rs
remove
called by 13
src/bitset.rs
digit_set
called by 12
src/board/candidate.rs
as_index
called by 11
src/board/digit.rs
overlaps
called by 10
src/bitset.rs

Shape

Method 163
Function 69
Class 37
Enum 11
Interface 3

Languages

Rust100%

Modules by API surface

src/board/sudoku.rs50 symbols
src/board/positions.rs43 symbols
src/strategy/solver.rs38 symbols
src/solver.rs36 symbols
tests/lib.rs19 symbols
src/bitset.rs18 symbols
src/generator.rs13 symbols
benches/lib.rs10 symbols
src/strategy/deduction.rs9 symbols
src/helper.rs9 symbols
src/parse_errors.rs8 symbols
src/board/digit.rs7 symbols

For agents

$ claude mcp add sudoku \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page