[Programmers/프로그래머스] 2021 Dev-Matching: 웹 백엔드 개발자(상반기) [코딩테스트]
- [Lv. 1] 로또의 최고 순위와 최저 순위
- [Lv. 2] 행렬 테두리 회전하기
- [Lv. 3] 다단계 칫솔 판매
- [Lv. 3] 헤비 유저가 소유한 장소
def solution(lottos, win_nums):
numbers = [0] * 46 # 0을 제외한 1~45까지의 각 숫자에 대해
for num in lottos:
numbers[num] += 1 # 구매번호의 숫자 증가
for num in win_nums:
numbers[num] += 1 # 당첨번호의 숫자 증가
ranking = [6, 6, 5, 4, 3, 2, 1] # 일치개수(인덱스)에 따른 순위 (0개 일치도 그 외에 포함)
min_match = numbers[1:].count(2) # 구매번호와 당첨번호가 일치하는(값이 2) 번호의 개수
max_match = numbers[1:].count(2) + numbers[0] # 알아볼수 없는 번호(0으로 표기된 번호)의 개수
answer = [ranking[max_match], ranking[min_match]] # 최고 순위, 최저 순위
return answer