codes/programmers
42840 모의고사
카제xd
2024. 12. 6. 22:11
https://school.programmers.co.kr/learn/courses/30/lessons/42840
def solution(answers):
first = [1,2,3,4,5]
second = [2,1,2,3,2,4,2,5]
third = [3,3,1,1,2,2,4,4,5,5]
f_c = 0
s_c = 0
t_c = 0
for i in range(len(answers)):
f_c += int(first[i%len(first)] == answers[i])
s_c += int(second[i%len(second)] == answers[i])
t_c += int(third[i%len(third)] == answers[i])
scores = [f_c, s_c, t_c]
max_c = max(scores)
max_p = [i+1 for i, s in enumerate(scores) if s == max_c]
return max_p
[개선할 점]
- answers 부분도 enumerate를 쓸 수도 있음.