import { validateCell } from '../utilities/sudoku-board-validator';

function getRandomIntBetween(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min);
}

export default function generateSudokuBoard() {
    let board = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0]
    ];
    let row = 0;
    let col = 0;

    const initialPopulatedCellsCount = getRandomIntBetween(18, 36);
    for (let i = 0; i < initialPopulatedCellsCount; i++) {
        while (!validateCell(row, col, board)) {
            row = getRandomIntBetween(0, 8);
            col = getRandomIntBetween(0, 8);
            board[row][col] = getRandomIntBetween(1, 9);
        }
    }
    return board;
}
@@ -589,28 +589,13 @@
 row 
-= 0;%0A    let col = 0
+, col
 ;%0A%0A 
@@ -661,16 +661,16 @@
 8, 36);%0A
-
     for 
@@ -716,24 +716,159 @@
 unt; i++) %7B%0A
+        row = getRandomIntBetween(0, 8);%0A        col = getRandomIntBetween(0, 8);%0A        board%5Brow%5D%5Bcol%5D = getRandomIntBetween(1, 9);%0A
         whil

Fix generation logic error