#sudoku #games #fun

bin+lib newdoku

A small library for displaying and solving Sudokus in ANSI-compliant terminals

7 releases (4 breaking)

Uses new Rust 2021

0.5.0 Jun 20, 2022
0.4.2 Jun 10, 2022
0.3.0 May 31, 2022
0.2.0 May 31, 2022
0.1.0 May 30, 2022

#34 in Games

Download history 34/week @ 2022-05-25 113/week @ 2022-06-01 76/week @ 2022-06-08 49/week @ 2022-06-15 31/week @ 2022-06-22 9/week @ 2022-06-29

169 downloads per month

MIT license

15KB
305 lines

Newdoku |

Simple Sudoku solver written in Rust. Method is inspired by a method briefly outlined in a CS lecture I had that I decided to try and implement based only on my understanding from the lecture.

It is called Newdoku because I started doing this a while ago and forgot about it and decided to restart, hence "New"

Quick Start

Library

use newdoku::Sudoku;

fn main() {
    let s = Sudoku::from_str(
        "xxxxxxx9xx9x7xx21xxx4x9xxxxx1xxx8xxx7xx42xxx5xx8xxxx748x1xxxx4xxxxxxxxxxxx9613xxx",
    );

    println!("{}\n\n{}", s, s.solution(0, false).unwrap());
}

See the docs for more info.

Binary

From source

$ git clone https://github.com/Piturnah/newdoku
$ cd newdoku
$ cargo run

From crates.io

$ cargo install newdoku
$ newdoku

Options

OPTIONS:
    -f, --file <FILE>    Load Sudoku from file
    -h, --help           Print help information
    -q, --quiet          No output until finished solving (faster)
    -s, --step <STEP>    Wait STEP millis between inserts [default: 0]
    -u, --uid <UID>      Load Sudoku by unique ID

When loading from a file, the parser parses any digit as a number in the sudoku. Any other character other than a newline will be parsed as an empty square.

Example sudoku: xxxxxxx9xx9x7xx21xxx4x9xxxxx1xxx8xxx7xx42xxx5xx8xxxx748x1xxxx4xxxxxxxxxxxx9613xxx

Gives

+-------+-------+-------+
| . . . | . . . | . 9 . |
| . 9 . | 7 . . | 2 1 . |
| . . 4 | . 9 . | . . . |
+-------+-------+-------+
| . 1 . | . . 8 | . . . |
| 7 . . | 4 2 . | . . 5 |
| . . 8 | . . . | . 7 4 |
+-------+-------+-------+
| 8 . 1 | . . . | . 4 . |
| . . . | . . . | . . . |
| . . 9 | 6 1 3 | . . . |
+-------+-------+-------+

Contributing

PRs and issues welcome.

Dependencies

~2.6–8MB
~142K SLoC