Application Kata "Minesweeper"

Write a program that creates a cheat sheet for a Minesweeper game field.

Minesweeper is a game that comes with some versions of Windows. The challenge is to uncover playing fields under which mines may lie. If a square is uncovered with a mine underneath it, the game is lost. Revealed squares are marked with numbers indicating how many mines are adjacent to the square.

The task of the "cheat sheet" program to be created is to create a cheat sheet showing the number of adjacent mines for each field.

An input file for the program looks like this:

*...
.... 
.*.. 
.... 

The program is then called up as follows:

C:> mogelzettel feld1.txt feld1mogel.txt
The result is the file feld1mogel.txt with the following content:
*100
2210
1*10
1110

Further examples of inputs and outputs of the program:

**...     **100
.....     33200
.*...     1*100

The field size can vary both in the number of rows and columns. However, the input files are always structured correctly and error handling is not required.

 

 

en_USEnglish