나의 풀이
def solution(lottos, win_nums):
answer = []
zero_cnt = lottos.count(0)
a = [x for x in lottos if x in win_nums]
max=zero_cnt+len(a)
min=len(a)
max =7-max if max >=1 else 6
min =7-max if max >=1 else 6
return [max, min]
다른 사람의 풀이
def solution(lottos, win_nums):
rank=[6,6,5,4,3,2,1]
cnt_0 = lottos.count(0)
ans = 0
for x in win_nums:
if x in lottos:
ans += 1
return rank[cnt_0 + ans],rank[ans]
'프로그래머스(파이썬) > LV.1(파이썬)' 카테고리의 다른 글
다트 게임→ 정규식, findall(), recompile() + 스택을 표방한 리스트 (0) | 2022.12.19 |
---|---|
체육복→ 앞에 확인하고, 뒤에 확인하고, set의 차집합(-)★ (0) | 2022.12.18 |
푸드 파이트 대회→deque() + while문 + cnt-=1→소모개념★★+ 우측에서 좌측으로 (0) | 2022.12.18 |
콜라 문제→ 치킨 쿠폰과 매우 유사★★ (0) | 2022.12.18 |
실패율★→collections의 Counter() 함수 vs count() 함수 + 정렬: 첫 번째 요소 내림차순, 두 번째 요소도 내림차순... (0) | 2022.12.18 |