Given a 2D array of mines, replace the question mark with the number of mines that immediately surround it. This includes the diagonals, meaning it is possible for it to be surrounded by 8 mines maximum.
The key is as follows:
minesweeper([
["-", "#", "-"],
["-", "?", "-"],
["-", "-", "-"]
]) ➞ [
["-", "#", "-"],
["-", "1", "-"],
["-", "-", "-"]
]
minesweeper([
["-", "#", "-"],
["#", "-", "?"],
["#", "#", "-"]
]) ➞ [
["-", "#", "-"],
["#", "-", "2"],
["#", "#", "-"]
]
minesweeper([
["-", "#", "#"],
["?", "#", ""],
["#", "?", "-"]
]) ➞ [
["-", "#", "#"],
["3", "#", ""],
["#", "2", "-"]
]
minesweeper([
["-", "-", "#"],
["?", "-", "-"],
["-", "-", "-"]
]) ➞ [
["-", "-", "#"],
["0", "-", "-"],
["-", "-", "-"]
]