Skip to content

markisayan/sudoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Sudoku solver

How it works

It uses 2 methods to solve the puzzle. First, a simple reasoning/elimination algorithm is used to solve the puzzle, by elmininating all the values that can't be written in a particular cell. Every cell is checked for vertical/horizontal/in-block repetitions. The process continues until the number of possible values for every cell reaches 1. If the puzzle isn't solved, a backtracking algorithm is called, which recursively inserts every remaining possible value that's left after applying the first algo. Then it checks if sudoku is still valid. Algorithm keeps going until there are no empty cells left.

In practice

I ran the code on the cpp.sh and input some of the most difficult sudoku puzzles out there. Here are the results

  • AI Escargot ~0.002 seconds
  • Golden Nugget (SE 11.9) ~0.066 seconds
  • Arto Inkala's puzzle ~0.017 seconds
  • Impossible #49 ~0.247 seconds

Note

This uses C++11 functionality.

About

Sudoku solver

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages