프로그래머스/Lv. 1
44. 로또의 최고 순위와 최저 순위
Seohyeong Lee
2024. 7. 16. 18:29
유형 : 구현
풀이 시간 : 한.. 10분?
def solution(lottos, win_nums):
answer = []
rankset = dict([[6-i, i+1] for i in range(5)])
rankset[0], rankset[1] = 6, 6
zeros = lottos.count(0)
correctnums = list(set(lottos) & set(win_nums))
return [rankset[len(correctnums)+zeros], rankset[len(correctnums)]]
간단히 풀었다.
최고 등수 = zero + 일치하는 숫자 개수
최저 등수 = 일치하는 숫자 개수이다.
*set의 교집합 = &
set의 합집합 = |
set의 차집합 = -
set의 대칭차집합 = ^