# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Limits
1s, 512 MB

The game of mines is a tricky one. You start with a grid and you click your way through the cells to find out what’s under them. If you click on a cell with a mine under it, it’s game over! If you click on a cell without a mine under it, you get to continue. Every time you uncover an empty cell, the cell may show a number indicating the number of mines that are around it in the 8 adjacent cells.

In this problem, you will be given a grid with the locations of all of the mines. You will then have to print the same grid with the appropriate numbers in the empty cells.

If a cell does not have any mine in its adjacent cells, you will leave the cell unchanged.

The input will start with two integers, **R** and **C** (0 < R, C ≤ 10). The following R lines will each contain C characters representing the contents of the corresponding cells.

An asterisk (*) is used to indicate a mine and a dot (.) is used indicate an empty cell.

Print the same grid, but with the appropriate numbers in the cells that has mines adjacent to them.

Input | Output |
---|---|

3 9 .**..*... ....*..** ..*...... | 1**22*222 1333*22** .1*211122 |

95% Solution Ratio

alexwiceEarliest,

showmic96Fastest, 0.0s

peppermintLightest, 0 B

SpellMasterShortest, 390B

Login to submit