function checkPosition(i, j, matrix){
  // get corresponding square from sudoku
  let boxSizeA;
  let boxSizeB;
  i < 3 ? boxSizeA = [0, 1, 2]:
  i < 6 ? boxSizeA = [3, 4, 5]:
  boxSizeA = [6, 7, 8];
  j < 3 ? boxSizeB = [0, 1, 2]:
  j < 6 ? boxSizeB = [3, 4, 5]:
  boxSizeB = [6, 7, 8];
  // check row and column
  for (let k = 0; k < 9; k++){
    const rowCondition = matrix[k][j] == matrix[i][j] && k != i;
    const columnCondition = matrix[i][k] == matrix[i][j] && k != j;
    if (rowCondition || columnCondition){
      return false;
    }
  }
  let answer = true;

  // check corresponding square
  boxSizeA.map((a) => {
    boxSizeB.map((b) => {
      const boxCondition = matrix[a][b] == matrix[i][j] && (a != i && b != j);
      if (boxCondition){
        answer = false;
      }
    });
  });
  return answer;
}
// returns false if current number can not be in current position
returns false if current number can not be in current position
returns false if current number can not be in current position
function checkPosition(i, j, matrix){
  let boxSizeA;
  let boxSizeB;
  i < 3 ? boxSizeA = [0, 1, 2]:
  i < 6 ? boxSizeA = [3, 4, 5]:
  boxSizeA = [6, 7, 8];
  j < 3 ? boxSizeB = [0, 1, 2]:
  j < 6 ? boxSizeB = [3, 4, 5]:
  boxSizeB = [6, 7, 8];
  for (let k = 0; k < 9; k++){
    const rowCondition = matrix[k][j] == matrix[i][j] && k != i;
    const columnCondition = matrix[i][k] == matrix[i][j] && k != j;
    if (rowCondition || columnCondition){
      return false;
    }
  }
  let answer = true;
  boxSizeA.map((a) => {
    boxSizeB.map((b) => {
      const boxCondition = matrix[a][b] == matrix[i][j] && (a != i && b != j);
      if (boxCondition){
        answer = false;
      }
    });
  });
  return answer;
}
function checkPosition ( i , j , matrix ) { let boxSizeA ; let boxSizeB ; i < 3 ? boxSizeA = [ 0 , 1 , 2 ] : i < 6 ? boxSizeA = [ 3 , 4 , 5 ] : boxSizeA = [ 6 , 7 , 8 ] ; j < 3 ? boxSizeB = [ 0 , 1 , 2 ] : j < 6 ? boxSizeB = [ 3 , 4 , 5 ] : boxSizeB = [ 6 , 7 , 8 ] ; for ( let k = 0 ; k < 9 ; k ++ ) { const rowCondition = matrix [ k ] [ j ] == matrix [ i ] [ j ] && k != i ; const columnCondition = matrix [ i ] [ k ] == matrix [ i ] [ j ] && k != j ; if ( rowCondition || columnCondition ) { return false ; } } let answer = true ; boxSizeA . map ( ( a ) => { boxSizeB . map ( ( b ) => { const boxCondition = matrix [ a ] [ b ] == matrix [ i ] [ j ] && ( a != i && b != j ) ; if ( boxCondition ) { answer = false ; } } ) ; } ) ; return answer ; }
returns false if current number can not be in current position
returns false if current number can not be in current position
// get corresponding square from sudoku // check row and column // check corresponding square