Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/james-p-d/sudoku
A Sudoku puzzle solver with algorithm in F# and UI in C# Winforms
https://github.com/james-p-d/sudoku
ai csharp fsharp sudoku winforms
Last synced: 18 days ago
JSON representation
A Sudoku puzzle solver with algorithm in F# and UI in C# Winforms
- Host: GitHub
- URL: https://github.com/james-p-d/sudoku
- Owner: James-P-D
- License: mit
- Created: 2019-11-21T19:46:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-04T20:44:13.000Z (over 3 years ago)
- Last Synced: 2024-11-17T10:36:01.619Z (3 months ago)
- Topics: ai, csharp, fsharp, sudoku, winforms
- Language: C#
- Homepage:
- Size: 325 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sudoku
A Sudoku puzzle solver with algorithm in F# and UI in C# Winforms![Screenshot](https://github.com/James-P-D/Sudoku/blob/master/Screenshot.gif)
## Method
Most Sudoku solvers I came across simply chose to implement [Peter Norvig's method](https://norvig.com/sudoku.html), but I decided I'd rather use the same method I use when solving the puzzle with pen-and-paper.
### Easy Cells
The easiest step for finding the value for a particular cell, is to find an empty cell and then figure out what it *can't* be.
For example, lets consider the following board taken from the [Guardian Easy Sudoku #4,612 from Mon 18 Nov, 2019](https://www.theguardian.com/lifeandstyle/2019/nov/18/sudoku-4612-easy).
![Easy Cells Screenshot](https://github.com/James-P-D/Sudoku/blob/master/Easy.png)
In the above initial board, concentrate on the 9x9 square in the middle-left of the board, and in this square, look at the cell in the very centre.
We can instantly tell that value of this cell can't be `3 or 5` because of other values in the 9x9 square. We can also tell that is can't be `1, 3 or 6` because of other cells in the same column. Finally, from analysing the values in the rest of the row we can also tell that it can't be `2, 3, 7, 8, or 9`. Putting all this information together and we know the cell can't be `1, 2, 3, 5, 6, 7, 8 or 9`, and must therefore be `4`.### Medium Cells
Having found all the easy cells, we find ourselves with the following board:
![Medium Cells Screenshot](https://github.com/James-P-D/Sudoku/blob/master/Medium.png)
There are no more easy solutions to be found, but let's consider the central 9x9 square.
This 9x9 square is missing the numbers `4, 5 and 6`. The numbers `4 and 5` could conceivably go in any of three available cells, but the number `6` *cannot* be on the top row because of the other `6` in the 9x9 square to the right. Therefore the `6` *must* be in the empty cell on the bottom row of the 3x3 square.### Hard Cells
Brute force. Still to be implemented.