-
Notifications
You must be signed in to change notification settings - Fork 332
/
Copy path6.py
30 lines (24 loc) · 953 Bytes
/
6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import List
def solution(m: int, n: int, board: List[str]) -> int:
board = [list(x) for x in board]
matched = True
while matched:
# 1) 일치 여부 판별
matched = []
for i in range(m - 1):
for j in range(n - 1):
if board[i][j] == \
board[i][j + 1] == \
board[i + 1][j + 1] == \
board[i + 1][j] != '#':
matched.append([i, j])
# 2) 일치한 위치 삭제
for i, j in matched:
board[i][j] = board[i][j + 1] = board[i + 1][j + 1] = board[i + 1][j] = '#'
# 3) 빈공간 블럭 처리
for _ in range(m):
for i in range(m - 1):
for j in range(n):
if board[i + 1][j] == '#':
board[i + 1][j], board[i][j] = board[i][j], '#'
return sum(x.count('#') for x in board)