## 🔒 문제. 로또 최고 순위와 최저 순위
def solution(lottos, win_nums):
answer = []
min_cnt = 0
zero_cnt = 0
for i in lottos:
win_idx = 0
if i != 0:
for j in win_nums:
if i == j and j != 0:
min_cnt += 1
win_idx += 1
elif i == 0:
zero_cnt += 1
if zero_cnt == 0 and min_cnt == 6: ## 6개 숫자 모두 맞춘 경우 (무조건 1등)
answer.append(1)
answer.append(1)
elif zero_cnt == 6 and min_cnt == 0: ## 6개 숫자 모두 0인 경우 (1등~6등)
answer.append(1)
answer.append(6)
elif zero_cnt + min_cnt <=1: ## 1개만 맞춘 경우 (또는 1개만 맞출 수 있는 경우) (무조건 6등-낙첨)
answer.append(6)
answer.append(6)
else: ## 그 외 경우
answer.append(7-(min_cnt+zero_cnt))
answer.append(7-(min_cnt))
return answer
## print(solution([44, 1, 0, 0, 31, 25], [31, 10, 45, 1, 6, 19]))
## print(solution([0, 0, 0, 0, 0, 0], [38, 19, 20, 40, 15, 25]))
## print(solution([45, 4, 35, 20, 3, 9], [20, 9, 3, 45, 4, 35]))
## print(solution([1,2,3,4,5,0], [7,8,9,10,11,12]))
Python/코테 연습