[Community Puzzle] Reverse Minesweeper

https://www.codingame.com/training/easy/reverse-minesweeper

Send your feedback or ask for help here!

Created by @psychedelic68,validated by @snoyes,@David_Augusto_Villa and @Alain-Delpuch.
If you have any issues, feel free to ping them.

hi,
i donā€™t understand why i have too much char and why the final count is bad.
the Tests 1 and 4 are OK.

[Mod edit: Please avoid posting codes on the forum in the future.]

Every one can help me please ?

Hi,

You have too many characters because some of your ā€œ9ā€ (the bombs) have their value increased by a bomb of the previous line so not only your logic donā€™t apply to them but they also are no longer just one digit.

ohhh thx, i didnā€™t think about that

greetings,
i tried to solve the puzzle and i think my solution works in a good way except for a problem with 3rd test case , it works well when i use a 50*50 table but increasing the parameters cause a problem in it (segmentation problem)
if anyone could help me iā€™ll be grateful ^^

[Mod edit: Please avoid posting codes on the forum in the future.]

Hi,

Issue is here:

                if (line[i-1][j-1] != '.')
                    line[i-1][j-1]+=1;
                if (line[i-1][j] != '.')
                    line[i-1][j]+=1;
                if (line[i-1][j+1] != '.')
                    line[i-1][j+1]+=1;     

When i is 0 you are accessing & modifying memory outside of the bounds of the array, segmentation problem occurs because you are changing the value of w.

Is there some bug in javascript? I answered the correct matrix (test 1), but it says it wants only the line where are the 111.

And now, itā€™s worse, I have ā€œattendu: Rienā€. But it doesnā€™t valid if I put console.log(ā€˜Rienā€™).

Please refer to the default code. It tells you how to output something in the error stream (as the standard stream is for answers only), e.g.
// To debug: console.error('Debug messages...');

And referring to your earlier message, I think itā€™s more likely that the bug is in your code. Maybe you could clarify which test you fail, and also copy and paste here the full error message(s) shown in the console.

This was interesting and fun to work on, I appreciate the answer and how it can either be really complex or very straightforward. Thank you for making this!

Hello all,

I tried to solve the puzzle, first in the case of 1 mine or none.
My output seems correct, but the tests donā€™t passā€¦ Is anyone can see what is wrong in my code please ?
Thanks !

[Mod edit: Please avoid posting codes on the forum in the future.]

I have found the solution, the last line should not have a /n

It does need an end of line character, but the print function in python is adding one at the end so you would have had two on the last line.

You could also have done (to prevent the print function adding an end of line):
print(str_sortie, end='')

1 Like

The tag says 2D array, but you only ever need to keep two lines in memory.

Well, to be fair, 2 lines makes a 2D array. :wink:

Thatā€™s weird. All my tests have passed in C#, but when I submit the code, test 4 fails. Obviusly, Iā€™m not using hard coded solutions. Any idea whatā€™s going on?

The exact same algorithm works fine in C++. All my tests and validators have passed. This means there is a problem in the C# solution.

I suppose it is up to you to make the tests and determine where the C# has issues.

I can give you a clue : the validator 4 is the only one having more lines than columns. Donā€™t you have a problem defining your lines/columns ?
Thatā€™s my guess.

1 Like

Yeap, found the problem. Thanks for the clue.

Really good puzzle, itā€™s funny how I see that people write complicated code or just few lines.
I belong to the first group, after submitting i see how i can optimize instead just using IF