Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 3 과제 제출 #22

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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