알고리즘

[프로그래머스] 로또의 최고 순위와 최저 순위

HHB 2023. 10. 7. 18:46
def solution(lottos, win_nums):
    answer = []
    yes = 0
    zero = 0
    win = {0:6, 1:6, 2:5, 3:4, 4:3, 5:2, 6:1}
    for i in range(6):
        if lottos[i] in win_nums:
            yes += 1
        elif lottos[i] == 0:
            zero += 1
            
    answer.append(win[yes+zero])
    answer.append(win[yes])
    return answer

 

728x90
반응형
LIST