GithubHelp home page GithubHelp logo

dagelf / sudoku Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emerentius/sudoku

0.0 0.0 0.0 11.78 MB

The Rust sudoku library

License: GNU Affero General Public License v3.0

Rust 100.00%

sudoku's Introduction

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 one of the world's fastest sudoku solver algorithm. A few modifications were made to improve the speed further.
Some competing solvers are fsss2, SK_BFORCE2 and tdoku. The latter is particularly strong for sudokus that don't have a unique solution or that are very hard. See also benchmarks done by tdoku's author: benchmarks (results at time of writing).

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.solution() {
    // print the solution in line format
    println!("{}", solution);

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

sudoku's People

Contributors

emerentius avatar aochagavia avatar reiniermaas avatar tianyishi2001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.