TIL/Algorithm
2021. 1. 4.
[프로그래머스] 모의고사(easy)
def solution(answers): answer = [] num_p1 = [1,2,3,4,5] num_p2 = [2,1,2,3,2,4,2,5] num_p3 = [3,3,1,1,2,2,4,4,5,5] n = len(answers) score = [0,0,0] for i in range(n): if answers[i] == num_p1[i%5]: score[0] += 1 if answers[i] == num_p2[i%8]: score[1] += 1 if answers[i] == num_p3[i%10]: score[2] += 1 max_score = max(score) for index, i in enumerate(score): if i == max_score: answer.append(index+1) ..