MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / check

Method check

Backtracking/Homework/sudokuSolver.cpp:17–37  ·  view source on GitHub ↗

Function to find a solved Sudoku.

Source from the content-addressed store, hash-verified

15 public:
16 //Function to find a solved Sudoku.
17 bool check(int grid[N][N],int row, int col, int num){
18 //row
19 for(int i=0;i<9;i++){
20 if(grid[i][col]==num) return false;
21 }
22 //col
23 for(int j=0;j<9;j++){
24 if(grid[row][j]==num) return false;
25 }
26 //box
27 int ini =row-row%3;
28 int inj=col-col%3;
29
30 for(int i=0;i<3;i++){
31 for(int j=0;j<3;j++){
32 if(grid[ini+i][inj+j]==num) return false;
33 }
34 }
35
36 return true;
37 }
38 bool helper(int grid[N][N], int row ,int col){
39 if (row==9) return true;
40 if (col==9) return helper(grid,row+1,0);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected