MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / isSafe

Function isSafe

assets/js/Sudoku_Solver.js:132–154  ·  view source on GitHub ↗
(board, r, c, no)

Source from the content-addressed store, hash-verified

130//returns a boolean true of false
131
132function isSafe(board, r, c, no) {
133
134
135 //not repeating in the same row or column
136 for (var i = 0; i < 9; i++) {
137 if (board[i][c] == no || board[r][i] == no) {
138 return false;
139 }
140 }
141 //subgrid
142 var sx = r - r % 3;
143 var sy = c - c % 3;
144
145 for (var x = sx; x < sx + 3; x++) {
146 for (var y = sy; y < sy + 3; y++) {
147 if (board[x][y] == no) {
148 return false;
149 }
150 }
151 }
152
153 return true;
154}
155
156function solveSudokuHelper(board, r, c) {
157

Callers 1

solveSudokuHelperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected