text: const { NotImplementedError } = require('../extensions/index.js');
  
  /**
   * In the popular Minesweeper game you have a board with some mines and those cells
   * that don't contain a mine have a number in it that indicates the total number of mines
   * in the neighboring cells. Starting off with some arrangement of mines
   * we want to create a Minesweeper game setup.
   *
   * @param {Array<Array>} matrix
   * @return {Array<Array>}
   *
   * @example
   * matrix = [
   *  [true, false, false],
   *  [false, true, false],
   *  [false, false, false]
   * ]
   *
   * The result should be following:
   * [
   *  [1, 2, 1],
   *  [2, 1, 1],
   *  [1, 1, 1]
   * ]
   */
  function minesweeper( matrix ) {
    const  rez = matrix.map((el, ind) => {
      return el.map((e, i) => {
        let count = 0
        if (matrix[ind - 1]) {
              if (matrix[ind - 1][i - 1]) count++;
              if (matrix[ind - 1][i]) count++;
              if (matrix[ind - 1][i + 1]) count++;
          }
          if (matrix[ind + 1]) {
              if (matrix[ind + 1][i - 1]) count++;
              if (matrix[ind + 1][i]) count++;
              if (matrix[ind + 1][i + 1]) count++;
          }
          if (matrix[ind][i - 1]) count++;
          if (matrix[ind][i + 1]) count++;
          
          return e = count
  
      })
    });
    return rez
  }
  
  module.exports = {
    minesweeper
  };
  