Scroll indicator done
728x90

https://school.programmers.co.kr/learn/courses/30/lessons/77484?language=python3


zero = 2 cnt = 2 -> 최저 5등(2개), 최고 3등(4개)
zero = 6 cnt = 0 -> 최저 6등(0개), 최고 1등(6개)
zero = 0 cnt = 6 -> 최저 1등(6개), 최고 1등(6개)
zero = 1 cnt = 5 -> 최저 2등(5개), 최고 1등(6개)

zero = lottos.count(0) 이란 게 있었다 ~ 괜히 리스트 원소 제거 함수 썼네 
if를 쓸 필요가 없었다 .. . .
def solution(lottos, win_nums):
    zero, cnt = 0, 0
    dic = {6:1, 5:2, 4:3, 3:4, 2:5, 1:6}  # cnt : score
    
    while 0 in lottos:
        lottos.remove(0)
        zero += 1

    for l in lottos:
        if l in win_nums:
            cnt += 1

    if cnt == 6:
        return [1, 1]
    elif cnt <= 5 and cnt >= 1:
        return [dic[cnt+zero], dic[cnt]]
    elif cnt == 0 and zero != 0:
        return [dic[cnt+zero], 6]
    elif cnt == 0 and zero == 0:
        return [6, 6]

< 수정 >

def solution(lottos, win_nums):
    zero, cnt = lottos.count(0), 0
    dic = {6: 1, 5: 2, 4: 3, 3: 4, 2: 5, 1: 6, 0: 6}  # cnt : score
    
    for l in lottos:
        if l in win_nums:
            cnt += 1
    return [dic[cnt+zero], dic[cnt]]

 

728x90