문제 링크
def solution(board, h, w): n = len(board) count = 0 move = [[0, -1], [1, 0], [0, 1], [-1, 0]] for i in move: dh, dw = h + i[0], w + i[1] if dh >= 0 and dh < n and dw >= 0 and dw < n: if board[h][w] == board[dh][dw]: count += 1 return count