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

이정연·2022년 10월 18일
0

CodingTest

목록 보기
65/165

문제 링크

CODE

from math import ceil
def solution(answers):
    answer = []
    first = [1,2,3,4,5]*ceil(len(answers)/5)
    second = [2,1,2,3,2,4,2,5]*ceil(len(answers)/8)
    third = [3,3,1,1,2,2,4,4,5,5]*ceil(len(answers)/10)
    f_cnt = 0
    s_cnt = 0
    t_cnt = 0
    for i in range(len(answers)):
        if answers[i] == first[i]:
            f_cnt += 1
        if answers[i] == second[i]:
            s_cnt += 1
        if answers[i] == third[i]:
            t_cnt += 1
    flag = max(f_cnt,s_cnt,t_cnt)
    if f_cnt == flag:
        answer.append(1)
    if s_cnt == flag:
        answer.append(2)
    if t_cnt == flag:
        answer.append(3)
    
    return answer
from math import ceil
ceil(float) # float를 올림하여 반환
profile
0x68656C6C6F21

0개의 댓글