![minesweeper google minesweeper google](https://i.ytimg.com/vi/2IN_XPGDCbw/maxresdefault.jpg)
You want to win the game as quickly as possible. This process continues, resulting in the following board: *.*.**.Īt this point, there are still un-revealed cells that do not contain mines (denoted by '.' characters), so the player has to click again in order to continue the game. There are no mines adjacent to the clicked cell, so when it is revealed, it becomes a 0, and its 8 adjacent cells are revealed as well. When all the cells that don't contain mines have been revealed, the game ends, and you win.įor example, an initial configuration of the board may look like this ('*' denotes a mine, and 'c' is the first clicked cell): *.*.**. Additionally, if the revealed cell contains a 0, then all of the neighbors of the revealed cell are automatically revealed as well, recursively. Two cells are neighbors if they share a corner or an edge. Otherwise, the revealed cell will contain a digit between 0 and 8, inclusive, which corresponds to the number of neighboring cells that contain mines. If the revealed cell contains a mine, then the game is over, and you lose. There are M mines hidden in M different cells of the grid. The content of each cell is initially hidden. In this problem, you are playing a game on a grid of identical cells. This problem has a similar idea, but it does not assume you have played Minesweeper. Minesweeper is a computer game that became popular in the 1980s, and is still included in some versions of the Microsoft Windows operating system. Note: If you have a different method from the ones discussed in answers, please share it so we can expand our knowledge of the different ways to solve this problem.
#MINESWEEPER GOOGLE CODE#
This is a problem from Google Code Jam qualification round (which is over now).