https://programmers.co.kr/learn/courses/30/lessons/64061
코딩테스트 연습 - 크레인 인형뽑기 게임
[[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
programmers.co.kr
"""
2019 카카오 개발자 겨울 인턴십
크레인 인형뽑기 게임
"""
def solution(board, moves):
answer = 0
basket = []
total_floor = len(board)
for x_position in moves:
x_position_index = x_position - 1
for y_position_index in range(total_floor):
current_doll = board[y_position_index][x_position_index]
if current_doll != 0:
board[y_position_index][x_position_index] = 0
if len(basket) >= 1 and basket[-1] == current_doll:
answer += 2
basket.pop()
else:
basket.append(current_doll)
break
return answer
print(solution(
[
[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]))
'Problem-solving > 프로그래머스' 카테고리의 다른 글
프로그래머스 - (2020 카카오 인턴십) 수식 최대화 (Python3) (0) | 2020.08.01 |
---|---|
프로그래머스 - (2020 카카오 인턴십) 키패드 누르기 (Python3) (0) | 2020.08.01 |
프로그래머스 - (2018 KAKAO BLIND RECRUITMENT) [3차] 파일명 정렬 (Python3) (0) | 2020.07.13 |
프로그래머스 - (2018 KAKAO BLIND RECRUITMENT) [3차] 압축 (Python3) (0) | 2020.07.13 |
프로그래머스 - (2018 KAKAO BLIND RECRUITMENT) [3차] 방금그곡 (Python3) (2) | 2020.06.26 |
댓글