사용 언어: python 3.9.5
https://programmers.co.kr/learn/courses/30/lessons/77484
level 1
최저
0 이 모두 다른 숫자라고 가정
→ 0이 아닌 숫자 중에 로또랑 같은 개수로 순위 결정
최고
0이 모두 맞다고 가정하고 순위 결정
→ 0인 숫자 + 0이 아닌 숫자 중에 로또랑 같은 개수로 순위 결정
import collections
def solution(lottos, win_nums):
lottos = sorted(lottos,reverse=True)
win_nums = sorted(win_nums,reverse=True)
answer = []
cnt = 0
cnt2 = 0
for l in lottos:
if l in win_nums:
cnt += 1
elif l == 0:
cnt2 += 1
answer.append(dict[cnt + cnt2])
answer.append(dict[cnt])
return answer
dict = collections.defaultdict(int)
dict = {6: 1, 5: 2, 4: 3, 3: 4, 2: 5, 1: 6, 0: 6}
# solution([45, 4, 35, 20, 3, 9], [20, 9, 3, 45, 4, 35])
성공
시작: 28분
(문제 읽기 6분, 풀기 22분)