[Python] 프로그래머스 - Level1 - 모의고사

강주형·2022년 8월 9일
0

https://school.programmers.co.kr/learn/courses/30/lessons/42840

완전탐색

def solution(answers):
    score = [0, 0, 0]
    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]
    
    for idx, val in enumerate(answers):
        if A[idx%len(A)] == val:
            score[0] += 1
        if B[idx%len(B)] == val:
            score[1] += 1
        if C[idx%len(C)] == val:
            score[2] += 1
    
    return [i+1 for i, s in enumerate(score) if s == max(score)]

다른 사람들 코드랑 비교해봐도 괜찮게 짠 것 같다.
풀다보니까 카카오 기출 아닌 다른 Level1은 난이도가 그렇게 높지 않은 것 같다.
Level2에 대한 공포심을 좀 덜어도 될 듯..

profile
Statistics & Data Science

0개의 댓글