Sudoku is one of the most popular puzzle games of all time. As a logic puzzle, Sudoku is also an excellent brain game. Being a tech savvy you can solve this by using your python programming skills. By using basic programming concepts like functions, loops and conditions we can build a Sudoku solver program.
- Sodoku is played on a grid of 9 X 9 spaces
- Within the rows and columns are 9 squares
- Each row, column needs to be filled out with the numbers 1-9, without repeating any numbers within the row, column or grid
Step 1: Creating a Sudoku solver
In this method for solving Sudoku puzzle
- Assign the size of the 2D matrix to variable size (M*M)
- Assign the puzzle to print the grid
Step 2: Finding unfilled cells and assigning value
- We will assign numto the row and col
- If we find same num in the same row or same column or in the specific 3*3 matrix.
- We match the next number
Step 3: Validating the entries
- Check if we have reached the end of the row and column
- Verify if the sum of values in a column, row and a 3X3 grid is 9
- If the value in the cell is greater than zero, iterate through the next column