Skip to content

Commit 70df8c8

Browse files
committed
Python: 24 PCCE 기출문제 9번
1 parent 958deb6 commit 70df8c8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(board, h, w):
2+
answer = 0
3+
color = board[h][w]
4+
n = len(board)
5+
dh, dw = [0, 1, -1, 0], [1, 0, 0, -1]
6+
7+
for i in range(4):
8+
h_check, w_check = h + dh[i], w + dw[i]
9+
if 0 <= h_check < n and 0 <= w_check < n:
10+
if color == board[h_check][w_check]:
11+
answer += 1
12+
13+
return answer

0 commit comments

Comments
 (0)