프로그래머스 LV 1(5)
2024. 1. 26. 21:09ㆍ백준 및 프로그래머스/프로그래머스 LV 1
-콜라 문제
-추억 점수
def solution(name, yearning, photo):
answer = []
for i in range(len(photo)):
total = 0
for j in range(len(photo[i])):
for k in range(len(name)):
if photo[i][j] == name[k]:
total += yearning[k]
answer.append(total)
return answer
-명예의 전당
def solution(k, score):
answer = []
tal = []
for i in range(len(score)):
answer.append(score[i])
answer.sort(reverse=True)
if len(answer) < k :
tal.append(answer[-1])
else:
tal.append(answer[k-1])
return tal
-카드뭉치
def solution(cards1, cards2, goal):
answer = ''
while True:
count = False
if len(goal) == 0:
answer+="Yes"
break
for i in range(len(cards1)):
if cards1[i] == goal[i]:
count = True
del cards1[i]
del goal[i]
break
else:
break
for j in range(len(cards2)):
if cards2[j] == goal[i]:
count = True
del cards2[j]
del goal[i]
break
else:
break
if not count:
answer+="No"
break
return answer'백준 및 프로그래머스 > 프로그래머스 LV 1' 카테고리의 다른 글
| 프로그래머스 LV1(6) (0) | 2024.01.29 |
|---|---|
| 프로그래머스 LV 1 (0) | 2024.01.28 |
| 프로그래머스 LV1(4) (0) | 2024.01.26 |
| 프로그래머스 LV1(3) (2) | 2024.01.26 |
| 프로그래머스 LV 1(2) (0) | 2024.01.25 |