• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 22, 2024 |35.2K Views

Sudoku (Visualisation)

  Share   Like
Description
Discussion

Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the digits from 1 to 9.

The naive approach is to generate all possible configurations of numbers from 1 to 9 to fill the empty cells. Try every configuration one by one until the correct configuration is found, i.e. for every unassigned position fill the position with a number from 1 to 9. 

After filling all the unassigned position check if the matrix is safe or not. If safe print else recurs for other cases.


Sudoku (Visualisation) : https://www.geeksforgeeks.org/sudoku-backtracking-7/