Algorithm for Solving Sudoku
I Want to Write a Code in Python to Solve a Sudoku Puzzle. Do You Guys Have Any Idea About a Good Algorithm for This Purpose. I Read Somewhere in Net About a...
I want to write a code in python to solve a sudoku puzzle. Do you guys have any idea about a good algorithm for this purpose. I read somewhere in net about a algorithm which solves it by filling the whole box with all possible numbers, then inserts known values into the corresponding boxes.From the row and coloumn of known values the known value is removed.If you guys know any better algorithm than this please help me to write one. Also I am confused that how i should read the known values from the user. It is really hard to enter the values one by one through console. Any easy way for this other than using gui?
11 Answers
Here is my sudoku solver in python. It uses simple backtracking algorithm to solve the puzzle. For simplicity no input validations or fancy output is done. It's the bare minimum code which solves the problem.
Must Read
Algorithm
- Find all legal values of a given cell
- For each legal value, Go recursively and try to solve the grid