728x90
문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42840?language=python3
난이도 : Lv.1
풀이
def solution(answers):
answer = []
a = [1, 2, 3, 4, 5]
b = [2, 1, 2, 3, 2, 4, 2, 5]
c = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
cnt = {1: 0, 2: 0, 3: 0}
for i in range(len(answers)):
if a[i%5] == answers[i]:
cnt[1] += 1
if b[i%8] == answers[i]:
cnt[2] += 1
if c[i%10] == answers[i]:
cnt[3] += 1
win = max(cnt.values())
for i in cnt:
if cnt[i] == win:
answer.append(i)
return answer
728x90