[프로그래머스 Lv1.] 로또의 최고 순위와 최저 순위(python)
1. 문제
문제 설명

제한사항
입출력 예시
입출력 예 설명
2. 풀이 과정
내가 생각한 진행 과정
- lottos에 있는 것과 win_nums에서 동일한 것(cnt), 0인 것(cnt_zero) 찾기
- cnt가 최저순위, cnt+cnt_zero가 최고순위가 됨
최종 코드
def solution(lottos, win_nums):
result = [6, 6, 5, 4, 3, 2, 1]
lottos.sort()
win_nums.sort()
cnt = 0
cnt_zero = 0
for lotto in lottos:
if lotto in win_nums:
cnt += 1
if lotto == 0:
cnt_zero += 1
answer = [result[cnt+cnt_zero], result[cnt]]
return answer
Author And Source
이 문제에 관하여([프로그래머스 Lv1.] 로또의 최고 순위와 최저 순위(python)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@78eeeeeee/프로그래머스-Lv1.-로또의-최고-순위와-최저-순위python저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)