카카오 게임을 직접 코딩하는 재미있는 문제를 풀어보았다.
내가 작성한 solution은 다음과 같다.
def solution(board, moves):
resultList = []
answer = 0
for i in moves :
j = 0
while j < len(board) :
if board[j][i-1] != 0 :
resultList.append(board[j][i-1])
board[j][i-1] = 0
if len(resultList) > 1 :
if resultList[-1] == resultList[-2] :
del resultList[-2:]
answer += 2
break
else :
j += 1
return answer