크레인 인형뽑기
Updated:
- 프로그래머스 level_1
간단한 구현 문제
입력값 〉 [[0, 0, 0, 0, 0], [0, 0, 1, 0, 3], [0, 2, 5, 0, 1], [4, 2, 4, 4, 2], [3, 5, 1, 3, 1]], [1, 5, 3, 5, 1, 2, 1, 4]
기댓값 〉 4
def solution(board, moves):
box = []
answer = 0
for i in range(len(moves)):
for j in range(len(board)):
if board[j][moves[i]-1]!=0:
box.append(board[j][moves[i]-1])
if len(box)>=2:
if box[len(box)-1] == box[len(box)-2]:
del box[len(box)-1]
del box[len(box)-1]
answer = answer+1
board[j][moves[i]-1] = 0
break
return answer*2
Leave a comment