Skip to content

RobinClaesson/SudokuSolver

Repository files navigation

Sudoku Solver

A .NET Sudoku solver that uses a combination of logical deduction and brute force to solve any Sudoku puzzle. Try it out at https://sudoku.robinclaesson.com/

It first tries to apply a series of logical rules to fill as many numbers as possible until no change is made. For simpler puzzles these rules can sometimes be enough to solve the puzzles. See the logical deduction rules section for details on the used rules.

If the logical rules are not enough to solve the puzzle the solver goes into a depth first brute force. It fills out the possible values for each remaining cells, and then picks one value for a cell and restarts the logical part. If it reaches a dead end it goes back up one step and tries another value. Since it restarts the logical rules after each "guess" the depth of the search is likely to be lower than the remaining number of cells at the first iteration.

Logical deduction rules

Applications

Web App

The easiest way to test the solver is via the Blazor WebAssembly webb-app available at https://sudoku.robinclaesson.com/.

Sudoku solver web app example run

Forms App

There is also a desktop forms app. It does however for now still require internet for fetching the puzzles via the api. Sudoku solver desktop app example run.

Core

.NET 8 class library for the solver and the supporting classes.

Roadmap (Unordered and SoonTm)

  • Manual entering of puzzles for Web and Forms
  • Settings for not rendering every step in solving (Improves performance)
  • Add more logical rules
  • Add image recognition to import grid from picture
  • Generate own puzzles
  • Create SolveAsync() for solving asynchronously
  • Save every solved step for replay (With depth-first tree?)

Credits - Puzzle generator API

The Sudoku puzzles solved by this program is being fetched from https://sudoku-api.vercel.app/ by Marcus0086.

About

Sudoku sover written in .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published