728x90
320x100
def solution(board, h, w):
n = len(board)
count = 0
dh,dw = [0, 1, -1, 0], [1, 0, 0, -1]
for i in range(4):
h_check, w_check = h + dh[i], w + dw[i]
if 0 <= h_check < n and 0 <= w_check < n and board[h][w] == board[h_check][w_check]:
count += 1
return count
728x90
320x100
'💻 하나씩 차곡차곡 > 프로그래머스 (Python)' 카테고리의 다른 글
[프로그래머스/python/Lv1] [PCCE 기출문제] 10번 / 데이터 분석 (0) | 2023.12.31 |
---|---|
[프로그래머스/python/Lv1] 성격 유형 검사하기 (0) | 2023.12.30 |
[프로그래머스/python/Lv1] 신규 아이디 추천 (0) | 2023.12.28 |
[프로그래머스/python/Lv1] 키패드 누르기 (0) | 2023.12.27 |
[프로그래머스/python/Lv1] 크레인 인형뽑기 (0) | 2023.12.26 |