동캄의 코딩도장

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

코테/프로그래머스

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

동 캄 2022. 9. 3. 16:00

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

 

프로그래머스

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

programmers.co.kr

# 프로그래머스 level1 성격 유형 검사하기

from collections import defaultdict


def solution(survey, choices):
    answer = ''
    lst = defaultdict(int)
    for i in range(len(choices)):
        l = list(map(str, survey[i]))
        if choices[i] == 4:
            continue
        elif choices[i] > 4:
            lst[l[1]] += (choices[i]-4)
        elif choices[i] < 4:
            lst[l[0]] += (4-choices[i])
    if lst['T'] > lst['R']:
        answer += 'T'
    else:
        answer += 'R'
    if lst['C'] >= lst['F']:
        answer += 'C'
    else:
        answer += 'F'
    if lst['J'] >= lst['M']:
        answer += 'J'
    else:
        answer += 'M'
    if lst['A'] >= lst['N']:
        answer += 'A'
    else:
        answer += 'N'
    print(lst)
    return answer


# print(solution(["AN", "CF", "MJ", "RT", "NA"], [5, 3, 2, 7, 5]))