본문 바로가기

Problem Solving

[Brute Force] 모의고사-programmers(Lv.1)

문제 제목 : 모의고사

문제 출처 : 프로그래머스 

알고리즘 : Brute Force

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

def solution(answers):
    ans = []; le = len(answers); trr = [5,0,1,0,3,0,4]; score = [0]*3; thrr = [3,3,1,1,2,2,4,4,5,5]
    for i in range(1,le+1):
        one = 5 if i%5 == 0 else i%5
        two = 2 if i%2>0 else trr[i%8]
        three = thrr[ (i-1)%10 ]
        if answers[i-1] == one: score[0]+=1
        if answers[i-1] == two: score[1]+=1
        if answers[i-1] == three: score[2]+=1
    maxi = max(score)
    for i,ival in enumerate(score):
        if ival == maxi: ans.append(i+1)
    if len(ans)>1:ans.sort()
    return ans