Skip to content
27 changes: 27 additions & 0 deletions 한예송/HW1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//220501
//프로그래머스 코딩테스트 연습 크레인 인형뽑기 게임
//https://programmers.co.kr/learn/courses/30/lessons/64061

def solution(board, moves):
basket = []
index = -1
count = 0
for i in moves:
for j in range(len(board)):
if j == len(board) - 1 and board[j][i-1] == 0:
break
elif board[j][i-1] == 0:
continue
else:
basket.append(board[j][i-1])
board[j][i-1] = 0
index += 1
break
if index < 1:
continue
elif basket[index] == basket[index-1]:
basket.pop()
basket.pop()
count += 2
index -= 2
return count