미숙한 제 풀이는 정답이 될 수 없으며, 이것보다 효율적인 코드는 당연히 존재합니다.
참고만 하여 주시고, 관련 피드백은 항상 환영합니다. 🤍
def solution(answers):
qnum=int(len(answers)/5)+1
score={1:0,2:0,3:0}
supo1 = [1,2,3,4,5]*qnum
supo2 = [2, 1, 2, 3, 2, 4, 2, 5]*qnum
supo3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]*qnum
for i in range (0,len(answers)):
if answers[i]==supo1[i]:
score[1]=score[1]+1
if answers[i]==supo2[i]:
score[2]=score[2]+1
if answers[i]==supo3[i]:
score[3]=score[3]+1
answer = sorted([k for k,v in score.items() if max(score.values()) == v])
return answer