프로그래머스 - 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
'코딩 테스트 > 프로그래머스' 카테고리의 다른 글
프로그래머스. 방의 개수 (0) | 2024.03.21 |
---|---|
프로그래머스. 정수 삼각형 (0) | 2024.03.20 |
프로그래머스. 순위 (0) | 2024.03.20 |
프로그래머스. 소수 만들기 (0) | 2024.03.19 |
프로그래머스. 가장 먼 노드 (0) | 2024.03.19 |