SMALL
문제 출처
코딩테스트 연습 - 로또의 최고 순위와 최저 순위
로또 6/45(이하 '로또'로 표기)는 1부터 45까지의 숫자 중 6개를 찍어서 맞히는 대표적인 복권입니다. 아래는 로또의 순위를 정하는 방식입니다. 1 순위 당첨 내용 1 6개 번호가 모두 일치 2 5개 번호
programmers.co.kr
풀이 코드
def solution(lottos, win_nums):
min, max = 0, 0
for lotto in lottos:
if lotto == 0:
max+=1
else:
if lotto in win_nums:
min+=1
max+=min
if min==0 and max!=0: answer = [7-max, 6]
if min==0 and max==0: answer = [6, 6]
if min!=0 and max!=0: answer =[7-max, 7-min]
return answer
LIST
'알고리즘-python > Programmers 문제' 카테고리의 다른 글
[프로그래머스/2단계/파이썬(Python3)] 삼각달팽이 (0) | 2021.07.07 |
---|---|
[프로그래머스/1단계/파이썬(Python3)] 모의고사 (0) | 2021.07.04 |
[프로그래머스/2단계/파이썬(Python3)] 가장 큰 수 (0) | 2021.06.27 |
[프로그래머스/2단계/파이썬(Python3)] H-index (0) | 2021.06.27 |
[프로그래머스/2단계/파이썬(Python3)] JadenCase 문자열 만들기 (0) | 2021.06.26 |