MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

**Background**

In mine-hunting games (e.g. Microsoft Minesweeper), the user is provided with a covered grid that, upon a left click, uncovers a hint as to the bombs around it or a bomb itself. The goal of this problem is to generate this grid based on the placement of a number of bombs and the puzzle size.

More information can be found on the Wikipedia page.

**Description**

You are provided with the row and column of *K* mines on a grid, *I* and *J* respectively, as well as the number of rows and columns on the grid, *M* and *N* respectively. Using this information, generate an *M* x *N* grid where the values on the grid represent the number of mines adjacent to that square or, if there is a mine on that particular square, the value -1.

**Example**

88 correct solutions
54 incorrect solutions

Last solution submitted on May 22, 2015

8 players like this problem

1 player likes this solution

6 players like this solution

1 Comment

Aurelien Queffurust
on 12 Jul 2012

wow wonderful solution!

1 Comment