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

Function initBoxes

assets/js/sudoku.js:272–302  ·  view source on GitHub ↗
(board)

Source from the content-addressed store, hash-verified

270 }
271
272 function initBoxes(board) {
273 var trio1,
274 trio2,
275 boxes = [];
276
277 for (var i = 0; i < 9; i++) {
278 boxes.push([]);
279 }
280
281 for (i = 0; i < 9; i++) {
282 if (i < 3) {
283 trio1 = 0;
284 } else if (i < 6) {
285 trio1 = 3;
286 } else {
287 trio1 = 6;
288 }
289 for (var j = 0; j < 9; j++) {
290 if (j < 3) {
291 trio2 = 0;
292 } else if (j < 6) {
293 trio2 = 1;
294 } else {
295 trio2 = 2;
296 }
297 board[j + 9 * i].boxId = trio1 + trio2;
298 boxes[trio1 + trio2].push(board[j + 9 * i]);
299 }
300 }
301 return boxes;
302 }
303 //====================================
304
305 //BOARD CHECKER FUNCTIONS

Callers 2

initSudokuBoardFunction · 0.85
SudokuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected