2
def calMines(self, board, x, y):15
r, c = x + d[0], y + d[1]16
if self.isValid(board, r, c) and (board[r][c] == "M" or board[r][c] == "X"):20
def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:21
x, y = click[0], click[1]23
if board[x][y] == "M":26
count = self.calMines(board, x, y)29
for r in range(x - 1, x + 2):30
for c in range(y - 1, y + 2):31
if self.isValid(board, r, c) and board[r][c] != "B":32
self.updateBoard(board, [r, c])34
board[x][y] = str(count)38
def isValid(self, board, a, b):39
return 0 <= a < len(board) and 0 <= b < len(board[0])