Python program to solve any Sudoku puzzle automatically. The program makes use of various AI techniques to solve any given sudoku quickly and effeciently
It has 6 functions, namely:
Display the values as a 2-D grid.
Convert grid string into {: } dict with '123456789' value for empties.
Eliminate values from peers of each box with a single value. Go through all the boxes, and whenever there is a box with a single value, eliminate this value from the set of values of all its peers.
Finalize all values that are the only choice for a unit. Go through all the units, and whenever there is a unit with a value that only fits in one box, assign the value to this box.
Iterate through eliminate() and only_choice(). If at some point, there is a box with no available values, return False. If the sudoku is solved, return the sudoku. If after an iteration of both functions, the sudoku remains the same, return the sudoku.
Using depth-first search and propagation, try all possible values. Creates seperate branch for every possible value and returns the branch that solves the sudoku.