프로그래머스/Lv. 1

54. 성격 유형 검사하기

Seohyeong Lee 2024. 7. 17. 02:16

유형 : 구현

풀이 시간 : 10분

 

이거 맞나? 구현.. 노가다..

def solution(survey, choices):
    answer = []
    survlist = [[survey[i][0], survey[i][1]] for i in range(len(survey))]
    resdict = dict([[j, 0] for j in ['R', 'T', 'C', 'F', 'J', 'M', 'A', 'N']])
    for i in range(len(choices)):
        if choices[i] <= 3:
            resdict[survlist[i][0]] += 4 - choices[i]
        elif choices[i] >= 5:
            resdict[survlist[i][1]] += choices[i] - 4
    if resdict['R'] >= resdict['T']:
        answer.append('R')
    else:
        answer.append('T')
    if resdict['C'] >= resdict['F']:
        answer.append('C')
    else:
        answer.append('F')
    if resdict['J'] >= resdict['M']:
        answer.append('J')
    else:
        answer.append('M')
    if resdict['A'] >= resdict['N']:
        answer.append('A')
    else:
        answer.append('N')
    return ''.join(answer)