프로그래머스 - 42840. 모의고사

2024. 3. 5. 23:56코딩 테스트/프로그래머스

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

 

프로그래머스

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

programmers.co.kr

 

전체 코드

def solution(answers):
    person1 = [1, 2, 3, 4, 5]
    person2 = [2, 1, 2, 3, 2, 4, 2, 5]
    person3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]

    val = [0, 0, 0]
    for i in range(len(answers)):
        if person1[i % len(person1)] == answers[i]:
            val[0] += 1

        if person2[i % len(person2)] == answers[i]:
            val[1] += 1

        if person3[i % len(person3)] == answers[i]:
            val[2] += 1

    answer = []
    for i in range(len(val)):
        if val[i] == max(val):
            answer.append(i + 1)

    return answer