728x90
문제 설명
문제 풀이 과정
- lottos에 있는 번호 중 win_nums에 있는 번호가 일치할 경우 count += 1
- 가려져있는 숫자 0이 전부 맞을 경우(count(0))는 최고 순위, 가려져 있지 않는 숫자만 일치할 경우가 최저 순위
- 맞는 개수가 0, 1개일 경우 6위이며, 맞는 개수에 따라 순위를 rank에 넣어줌
- 맞는 개수에 따라 값 반환
def solution(lottos, win_nums):
rank = [6, 6, 5, 4, 3, 2, 1]
count = 0
cnt_0 = lottos.count(0)
for i in win_nums:
if i in lottos:
count += 1
return rank[count+ cnt_0], rank[count]
- coding test url:
https://school.programmers.co.kr/learn/courses/30/lessons/77484
728x90
'Coding test' 카테고리의 다른 글
[Programmers] 롤케이크 자르기 (2) | 2022.12.23 |
---|---|
[Programmers] 할인 행사 (0) | 2022.12.20 |
[KAKAO BLIND RECRUITMENT] 신고 결과 받기(python) (0) | 2022.12.16 |
[KAKAO TECH INTERNSHIP 2022] 성격 유형 검사하기(python) (0) | 2022.12.16 |
[Programmers] 숫자 짝꿍 (0) | 2022.12.12 |