field:
- 'M': a hidden mine;
- 'E': a hidden empty cell;
- 'B': an opened cell with no mines around it (the neighbours are the 8 surrounding cells, diagonals included);
- a digit from '1' to '8': an opened cell with that many mines around it.
The player clicks the hidden cell cell = [row, col]. Return the board after this move:
- if it is a mine 'M', it becomes 'X' and nothing else changes;
- if it is an empty cell with mines around it, it shows their count;
- if there are no mines around, the cell becomes 'B' and all its hidden empty neighbours open the same way, and so on down the chain.field=[['E', 'E', 'E'], ['E', 'E', 'E'], ['E', 'E', 'M']], cell=[0, 0] → [['B', 'B', 'B'], ['B', '1', '1'], ['B', '1', 'M']]
There are no mines next to (0, 0), so it becomes 'B' and the opening spreads. Cells touching the mine get '1'; the mine itself stays hidden.
field=[['E', 'M'], ['M', 'E']], cell=[0, 0] → [['2', 'M'], ['M', 'E']]
The cell has two neighbouring mines, so it becomes '2' and nothing else opens.
field=[['B', '1', 'E'], ['B', '1', 'M']], cell=[1, 2] → [['B', '1', 'E'], ['B', '1', 'X']]
A mine is opened: it turns into 'X' and the game is over.
'M', 'E', 'B' or digits from '1' to '8'cell points to a cell holding 'M' or 'E'field=[['E', 'E', 'E'], ['E', 'E', 'E'], ['E', 'E', 'M']], cell=[0, 0]
[['B', 'B', 'B'], ['B', '1', '1'], ['B', '1', 'M']]
Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.