본문 바로가기
코테준비/프로그래머스

모의고사(LV1)

by 알래스카코코넛 2025. 6. 21.
반응형

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

 

초짜라 좀 더럽게 풀었습니다 

반응형