삽집하는 개발들/알고리즘

[49일차][Lv1][프로그래머스][2023 Dev-Matching: 웹 백엔드 개발][77484]로또의 최고 순위와 최저 순위

악투 2023. 8. 29. 21:41
반응형
def solution(lottos, win_nums):
    rank_obj = { '0' : 6, '1' : 6, '2': 5 , '3' : 4, '4' : 3, '5' : 2 , '6' : 1 }
    result = []
    zero_count = 0
    check_count = 0
    
    for lotto in lottos:
        if lotto == 0:
            zero_count += 1
        if lotto in win_nums:
            check_count += 1
    
    if zero_count == 0:
        return [rank_obj[str(check_count)], rank_obj[str(check_count)]]        
    elif zero_count == 6:
        return [rank_obj[str(zero_count)], zero_count]
    else:
        max_count = zero_count+check_count         
        return [rank_obj[str(max_count)], rank_obj[str(check_count)]]
반응형