본인의 로또 번호에서 결측값이 있음. 당첨 번호와 비교하여 본인의 로또 순위 범위를 산출함.
https://programmers.co.kr/learn/courses/30/lessons/77484
def solution(lottos, win_nums):
#answer default
answer = [0]*2
# win_dict (key: #hit, values: #win)
win_dict = {6:1, 5:2, 4:3, 3:4, 2:5, 1:6, 0:6}
# lowest
lowest_hit = len(set(win_nums).intersection(set(lottos)))
answer[1] = win_dict[lowest_hit]
# highest
len_missing = len([l for l in lottos if l == 0])
answer[0] = win_dict[lowest_hit + len_missing]
return answer
set1.intersection(set2)로 해결함.
def solution(lottos, win_nums):
win_info = {6:1,5:2,4:3,3:4,2:5,1:6,0:6}
lowest = len(set(win_nums).intersection(set(lottos)))
return win_info[lowest + lottos.count(0)], win_info[lowest]