An open API service indexing awesome lists of open source software.

https://github.com/lukashedegaard/sudoku-solver-rust


https://github.com/lukashedegaard/sudoku-solver-rust

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# Sudoku solver in Rust

This repo contains a Sudoku solver which uses recursion and [backtracking](https://en.wikipedia.org/wiki/Backtracking) in its implementation.

## Usage
1. [Install Rust](https://www.rust-lang.org/tools/install).
1. Modify sudoku in `src/main.rs`
1. Run example with `cargo run`.

```bash
Initial:
['9', '.', '6', '5', '7', '.', '4', '2', '.']
['5', '.', '2', '1', '4', '.', '8', '.', '.']
['.', '.', '4', '.', '.', '.', '.', '.', '5']
['.', '.', '5', '.', '.', '.', '6', '.', '3']
['8', '.', '3', '.', '.', '.', '2', '.', '4']
['4', '.', '7', '.', '.', '.', '.', '.', '.']
['2', '.', '.', '.', '.', '.', '5', '.', '.']
['.', '.', '8', '.', '1', '6', '.', '.', '2']
['.', '4', '.', '.', '2', '5', '.', '.', '9']

Solution:
['9', '8', '6', '5', '7', '3', '4', '2', '1']
['5', '3', '2', '1', '4', '9', '8', '6', '7']
['7', '1', '4', '2', '6', '8', '9', '3', '5']
['1', '2', '5', '4', '8', '7', '6', '9', '3']
['8', '9', '3', '6', '5', '1', '2', '7', '4']
['4', '6', '7', '3', '9', '2', '1', '5', '8']
['2', '7', '9', '8', '3', '4', '5', '1', '6']
['3', '5', '8', '9', '1', '6', '7', '4', '2']
['6', '4', '1', '7', '2', '5', '3', '8', '9']
```

## Performance
The programme solves a "hard" sudoku in approx. 0.3 seconds.