반응형
def solution(answers):
answer = []
k = len(answers)
cnt1 = 0
cnt2 = 0
cnt3 = 0
std1 = [x for x in range(1,6)]*2000
std1_new = std1[:k]
std2 = [2,1,2,3,2,4,2,5]*1250
std2_new = std2[:k]
std3 = [3,3,1,1,2,2,4,4,5,5]*1000
std3_new = std3[:k]
for i in range(k):
if std1_new[i] == answers[i]:
cnt1 +=1
for i in range(k):
if std2_new[i] == answers[i]:
cnt2 +=1
for i in range(k):
if std3_new[i] == answers[i]:
cnt3 +=1
total = [cnt1, cnt2, cnt3]
if max(total) == cnt1:
answer.append(1)
if max(total) == cnt2:
answer.append(2)
if max(total) == cnt3:
answer.append(3)
return answer
초짜라 좀 더럽게 풀었습니다
반응형
'코테준비 > 프로그래머스' 카테고리의 다른 글
명예의 전당 (1) Python (1) | 2025.06.20 |
---|---|
카드 뭉치(Lv.1) (0) | 2025.06.18 |
최소 직사각형 (Python) (0) | 2025.05.16 |
완주하지 못한 선수 (프로그래머스, Python) (0) | 2025.05.16 |
프로그래머스 2021 KAKAO BLIND RECRUITMENT 신규 아이디 추천 - 파이썬 (0) | 2025.02.17 |