-
모의고사프로그래밍/알고리즘 2021. 3. 25. 18:06
참고해서 푼 풀이
def solution(answers): student1 = [1, 2, 3, 4, 5] student2 = [2, 1, 2, 3, 2, 4, 2, 5] student3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] score = [0, 0, 0] result = [] for index, answer in enumerate(answers): if answer == student1[index % len(student1)]: score[0] += 1 if answer == student2[index % len(student2)]: score[1] += 1 if answer == student3[index % len(student3)]: score[2] += 1 for index, s in enumerate(score): if s == max(score): result.append(index + 1) return result
728x90반응형LIST'프로그래밍 > 알고리즘' 카테고리의 다른 글
수박수박수박수박수박수? (0) 2021.03.25 문자열 내림차순으로 배치하기 (0) 2021.03.25 문자열 내 p와 y의 개수 (0) 2021.03.23 서울에서 김서방 찾기 (0) 2021.03.23 같은 숫자는 싫어 (0) 2021.03.23