def count_rank_matching(count):
if count == 6:
rank = 1
elif count == 5:
rank = 2
elif count == 4:
rank = 3
elif count == 3:
rank = 4
elif count == 2:
rank = 5
else:
rank = 6
return rank
def solution(lottos, win_nums):
answer = []
zero = 0
for num in lottos:
if num == 0:
zero+=1
count = len(list(set(win_nums).intersection(lottos)))
min_count = count
max_count = count+ zero
answer=[count_rank_matching(max_count),count_rank_matching(min_count)]
return answer
문제 풀이 (Python 코드)
728x90
반응형
'알고리즘 공부' 카테고리의 다른 글
[ LeetCode] Letter Combinations of a Phone Number 문제 풀이(Backtracking/백트레킹/Python/파이썬) (0) | 2021.12.28 |
---|---|
[프로그래머스] 베스트앨범(파이썬/python/해시) (0) | 2021.12.13 |
[프로그래머스] 더 맵게 (Python) (0) | 2021.12.12 |
[프로그래머스] 완주하지 못한 선수 (Python) (0) | 2021.12.12 |
[프로그래머스]숫자 문자열과 영단어(Python) (0) | 2021.12.12 |