Duplicate

# [1차] 프렌즈4블록

### 코드

from copy import deepcopy def process(board): newboard = deepcopy(board) v = 0 for r in range(len(board) - 1): for c in range(len(board) - 1): if board[r][c] == board[r+1][c] == board[r][c+1] == board[r+1][c+1]: if board[r][c] != '-': if newboard[r][c] != '-': v += 1 if newboard[r+1][c] != '-': v += 1 if newboard[r][c+1] != '-': v += 1 if newboard[r+1][c+1] != '-': v += 1 newboard[r][c] = '-' newboard[r+1][c] = '-' newboard[r][c+1] = '-' newboard[r+1][c+1] = '-' return v, newboard def movedown(board): newboard = [['-' for _ in range(len(board))] for _ in range(len(board))] for c in range(len(board)): level = len(board) - 1 for r in range(len(board) - 1, -1, -1): if board[r][c] != '-': newboard[level][c] = board[r][c] level -= 1 return newboard def solution(m, n, board): answer = 0 board = [list(r) for r in board] while True: v, board = process(board) answer += v if v == 0: return answer board = movedown(board)
Python
복사

### 출처

프로그래머스 코딩테스트 연습 https://school.programmers.co.kr/learn/challenges