Algorithm (PS)

[카카오] 성격 유형 검사하기 Python 풀이

minjiwoo 2022. 9. 26. 22:07
728x90

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

 

프로그래머스

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

programmers.co.kr

mbti 점수 계산하는 재미있는 문제이다 

처음에 놓친 부분은 매우 비동의가 3점으로 들어가야 하는데 이걸 1점으로 거꾸로 계산했다 
레벨 1의 구현문제이다 

def solution(survey, choices):
    answer = ''
    n = len(choices)
    type = {'R':0, 'T':0, 'C':0, 'F':0, 'J':0, 'M':0, 'A':0, 'N':0}
    score = [0, 3, 2, 1, 0, 1, 2, 3]
    for i in range(n):
        if choices[i] == 4:
            continue
        if choices[i] < 4:
            type[survey[i][0]] += score[choices[i]]
        if choices[i] > 4:
            type[survey[i][1]] += score[choices[i]]
    print(type)
    if type['R'] >= type['T']:
        answer += 'R'
    else:
        answer += 'T'
    
    if type['C'] >= type['F']:
        answer += 'C'
    else:
        answer += 'F'
        
    if type['J'] >= type['M']:
        answer += 'J'
    else:
        answer += 'M'
    
    if type['A'] >= type['N']:
        answer += 'A'
    else:
        answer += 'N'
    return answer
728x90