[프로그래머스]-level1-성격 유형 검사하기-Python[파이썬]

s2ul3·2022년 11월 12일
0
post-custom-banner

문제링크

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

문제설명

알고리즘

코드

def solution(survey, choices):
    type_lst = ['R', 'T', 'C', 'F', 'J', 'M', 'A', 'N']
    type_dict = dict()
    for t in type_lst:
        type_dict[t] = 0
    for s, c in zip(survey, choices):
        not_t = s[0]
        agree_t = s[1]
        if c < 4:
            type_dict[not_t] += 4-c
        elif c > 4:
            type_dict[agree_t] += c-4
    print(type_dict)

    answer = '' 
    if type_dict['R'] >= type_dict['T']:
        answer+='R'
    else:
        answer+='T'

    if type_dict['C'] >= type_dict['F']:
        answer+='C'
    else:
        answer+='F'

    if type_dict['J'] >= type_dict['M']:
        answer+='J'
    else:
        answer+='M'

    if type_dict['A'] >= type_dict['N']:
        answer+='A'
    else:
        answer+='N'

    return answer
profile
statistics & computer science
post-custom-banner

0개의 댓글