Gamified challenge · Neighbour counting
board is a covered field: each row is a string where * is a buried mine and . is a covered safe square. The player uncovers square (r, c) (row r, column c).
If it's a mine, it becomes X and nothing else changes. Otherwise it shows a digit 0–8: how many of its 8 neighbours (diagonals included) are mines. A square showing `0` automatically uncovers all its covered neighbours too, which may be 0s that open further. Mines that weren't hit stay *; squares never reached stay ..
Write reveal(board, r, c) that returns the board after the click. Example: reveal(["*..", "...", "..."], 2, 2) → ["*10", "110", "000"]: the corner (2, 2) is a 0, so the opening spreads until it reaches the squares touching the mine.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google