RPA Challenge: Minesweeper

I had an idea for a fun RPA challenge.

A customer sends you a minesweeper puzzle and wants you to write out the numbers that go next to a grid of mines as shown in the attached workbook: Minesweeper_InputExample.xlsx (9,6 Ko) .

The workbook will contain a border-lined grid with asterisks representing mines in the grid. Your task is to generate a new workbook with numbers in the empty cells where there is a mine nearby. The number will indicate how many mines are next to the grid location in cardinal and diagonal directions (see attached output example: Minesweeper_OutputExample.xlsx (8,9 Ko) ).

Create a project which takes the height of the grid as an Int32, the width of the grid as an Int32, the path to the input workbook (relative to the project), and the path to the output workbook (relative to the project).

For more on how the numbers are generated in a game of Minesweeper, see https://www.instructables.com/id/How-to-play-minesweeper/.

Input: You will be given the dimensions of the grid, so you will not need to code for determining this in the workflow. You will be given the input workbook, which will be formatted as in the attached examples. This will not necessarily be a square grid, and may be wider or taller depending on the input height and width.

Please let me know if you have any questions, and I look forward to seeing the solutions you all come up with!

3 Likes

This is my solution.

I havenâ€™t tested it against more than say the example grid, a larger grid and a super large grid. But the output looks spot on for each so I am happy.

Itâ€™s quite simple in the end, however, it took a little time as I went down a rabbit hole of trying to work through errors when the bot tried to grab a cell that was outside the grid, such as the Last Row + 1. In the end, I just set the bot to ignore such errors rather than building in some logic to track when it was looking at the last row/last column etc. So there are multiple try catch blocks to do this.

Itâ€™s probably not the most elegant as it simply ignores errors rather than avoiding them, so I am interested to see if anyone else has come up with a better one. However, it works as required.

The output is saved to the folder the workflow is in as â€śYourMinesweeperGrid_Output.csvâ€ť. Just place the input into the input folder and run.

Minesweeper_V2.zip (17.7 KB)

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.