프로그래머스 코딩테스트/Python
프로그래머스 모의고사 Python
Coding-Su
2024. 6. 28. 15:59
728x90
정답
def solution(answers):
answer = []
p1 = [1, 2, 3, 4, 5]
p2 = [2, 1, 2, 3, 2, 4, 2, 5]
p3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
pc = [0, 0, 0]
for i in range(0, len(answers)):
if answers[i] == p1[i%5]:
pc[0] += 1
if answers[i] == p2[i%8]:
pc[1] += 1
if answers[i] == p3[i%10]:
pc[2] += 1
if max(pc) == pc[0]:
answer.append(1)
if max(pc) == pc[1]:
answer.append(2)
if max(pc) == pc[2]:
answer.append(3)
return answer
728x90