Fill in the numbers of a Minesweeper board. grid is a list of equal-length strings where
* is a mine and . is empty. Return a new list of strings where every * stays and every
. is replaced by the number of mines among its up to eight neighbours (horizontal, vertical
and diagonal), written as a single digit.
Examples
Input: grid = ["*..", "...", "..*"]
Output: ["*10", "121", "01*"]
Input: grid = ["."]
Output: ["0"]
Constraints
0 <= len(grid) <= 30, rows have equal length between1and30.
Goals
- Visit the eight neighbours of a cell with two small loops
- Stay inside the grid bounds when looking at neighbours