This question evaluates a candidate's ability to implement grid-based data structures, state management, and flood-fill style expansion logic for Minesweeper, including correct handling of mine revelation and idempotent re-click behavior.
Implement a playable text-based Minesweeper engine.
You are given a board size and mine locations (or a mine count with a deterministic placement method). Implement initialization and the click operation.
height
rows and
width
columns.
Implement click(r, c) with these rules:
(r, c)
contains a mine, mark it as revealed and the game is over.
(r, c)
.
print
(e.g., hidden cells shown as
#
, revealed numbers as
0-8
, mines as
*
only when revealed).
1 ≤ width, height ≤ 200
(assume up to 40,000 cells).
width*height - 1
.