알고리즘/프로그래머스

[Python] 모의 고사

dding96 2022. 12. 23. 13:17

https://school.programmers.co.kr/learn/courses/30/lessons/42840

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

  • 나의 풀이
# 모의고사

def solution(answers):
    supo_1 = 0
    supo_2 = 0
    supo_3 = 0
    
    supo_1_pattern = [1,2,3,4,5] * 8
    supo_2_pattern = [2,1,2,3,2,4,2,5] * 5
    supo_3_pattern = [3,3,1,1,2,2,4,4,5,5] * 4
    
    for i in range(len(answers)):
        idx = i % 40
        if supo_1_pattern[idx]==answers[i]:
            supo_1 += 1
        if supo_2_pattern[idx]==answers[i]:
            supo_2 += 1
        if supo_3_pattern[idx]==answers[i]:
            supo_3 += 1
            
    score = [supo_1, supo_2, supo_3]
    max_score = max(score)
    answer = []
    
    for i in range(3):
        if score[i] == max_score:
            answer.append(i+1)
    return sorted(answer)