Canton Software Craftsmanship Message Board › Monthly Mentorship Challenge #3 Now with more Minesweeper
|Shawn Michael C.||
Write code and be adored! ;) Pull requests at the github repo at the bottom of this page. Mike Geig lead us off this month with some cool C++ and Java examples. I'm working on python, Objective-C, and Go but please solve it in whatever language you want to. Last month was really cool having lots of examples in different languages. Ready, set, CODE!
You will be given an M*N matrix. Each item in this matrix is either a '*' or a '.'. A '*' indicates a mine whereas a '.' does not. The objective of the challenge is to output a M*N matrix where each element contains a number (except the positions which actually contain a mine which will remain as '*') which indicates the number of mines adjacent to it. Notice that each position has at most 8 adjacent positions e.g. left, top left, top, top right, right, ...
Your program should accept as its first argument a path to a filename. Each line in this file contains M,N, a semicolon and the M*N matrix in row major form. e.g.
Print out the new M*N matrix (in row major form) with each position(except the ones with the mines) indicating how many adjacent mines are there. e.g.