Skip to content

rohkash/SudokuSolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

SudokuSolver

This solver can be broken down into 5 parts. There is a board, which is essentially a 2d array where each element is a row, and the nth element of each inner list forms a column. The print_board function allows you to have a nice visual design of the sudoku board in the terminal, but I am currently in the midst of learning Tkinter and will soon implement a nice GUI to go along with this project. The find_empty function looks for the next 0, which represents an empty spot in the board. the valid function checks if putting a number in the spot doesn't conflict with the row, column, and square it is in. Finally, the solver uses a backtracking algo, or in other words it will try numbers 1 through 9 on the empty spot until it finds something valid and then moves on to the next empty spot. If it cycles past 9, it will go back to the previous empty spot and try one higher than what it was before (if that's even valid, if not it'll cycle through till 9) and if the previous spot also cannot find a valid number between 1-9 to make the next one valid, it'll go to the one before and repeat the process. This is essentially the backtracking, and it is much more efficient than just trying every single combination that could exist on this board.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages