문제
코드
def solution(lottos: list, win_nums: list) -> list:
hits = {0: 6, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1}
hit_num, zero_num = 0, 0
for lotto in lottos:
if lotto in win_nums:
hit_num += 1
if lotto == 0:
zero_num += 1
return [hits[hit_num + zero_num], hits[hit_num]]
if __name__ == '__main__':
print(solution([44, 1, 0, 0, 31, 25], [31, 10, 45, 1, 6, 19]))
print(solution([0, 0, 0, 0, 0, 0], [38, 19, 20, 40, 15, 25]))
print(solution([45, 4, 35, 20, 3, 9], [20, 9, 3, 45, 4, 35]))
결과
출처 & 깃허브
programmers 로또의 최고 순위와 최저 순위
github