티스토리 뷰

def solution(answers):
    answer = []
    first_ = 0
    second_ = 0
    third_ = 0
    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]
    for idx, i in enumerate(answers):
        if i == first[idx%len(first)]:
            first_ = first_ + 1
        if i == second[idx%len(second)]:
            second_ = second_ + 1
        if i == third[idx%len(third)]:
            third_ = third_ + 1
    max_ = max(first_, second_, third_)

    if max_ == first_:
        answer.append(1)
    if max_ == second_:
        answer.append(2)
    if max_ == third_:
        answer.append(3)

    return answer

내 풀이가 젤 무난한 풀이.

나는 파이썬 쓰면서 가독성 떨어지게까지 간단하게 코드 짜는 걸 좋아하지 않는다.

 

그냥 엄청 돌아가지만 않으면 된다 주의임.

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/10   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함