[Community Puzzle] Minesweeper level generator

Yes, it seems I had same issues as you had. The takeaway is “do not calculate it in whatever Int/Bigint/etc your language uses by default” but instead “use 32-bit unsigned integers for all intermediary variables and constants”. That seems to be the only way to do it, anyway.

A similar takeaway seems to be do not use languages that use Floats/Doubles/etc for computation on integers. I am pointing onto the gentleman above who used TypeScript.

I’m failing the last validator. Can anyone give me a hint or the input for it?

You’ve found and fixed the issue after posting the message, right? :wink:

Yes I found it :slight_smile:
I had an array of size m (num mines to place) where each element contained was a tuple containing x and y of all yet placed mines. When I was generating the mine positions I was checking the array if there is already a mine. What I didn’t had in mind was that the whole array was initialized with 0,0 x,y entries. In the last validator I rolled a mine on pos 0,0. I checked the array and detected a mine at 0,0 but this was an error. I’ve replaced that array with a List that grows dynamically and the error was fixed. Thanks for all the people in the discord that pointed me in the right direction :slight_smile:

1 Like

Always same position for first test.
1 0
1 4
5 3
2 4

The 4th it’s incorrect.
Test in Rust, C, C++ (all 3 with u32 variable) and Python (for fun with modulo ich 2^32).
Someone has done in this language ?

EDIT :
Ho reread the statement… problem was to an other place…

Note, with bit-and, it’s easy in Python (and other language).

Note (2), i’m oppose to puzzles with overflow mekanism; never be a good pratice in any language.