BOJ
2022 KAKAO TECH INTERNSHIP : 성격 유형 검사하기
이도울
2023. 11. 13. 10:56
SMALL
7점을 기준으로 4점보다 높고, 낮음에 따라 해당 성격 유형에 주어지는 점수가 달라져야 한다.
defaultdict를 import해서 int형으로 선언하고, 값이 같을 때 알파벳 순으로 나오는 것은 순서가 빠른 알파벳 >= 그 다음 순서 알파벳으로 조건을 두면 순서가 빠른 알파벳이 answer에 더해진다.
from collections import defaultdict
def solution(survey, choices):
answer = ''
n = len(survey)
myDict = defaultdict(int)
for i in range(n):
determine = choices[i]
if(determine == 4) :
continue
elif(determine < 4) : # 1,2,3
myDict[survey[i][0]] += 4 - (determine)
elif(determine > 4) : # 5,6,7
myDict[survey[i][1]] += determine - 4
if(myDict['R'] >= myDict['T']):
answer += 'R'
else :
answer += 'T'
if(myDict['C'] >= myDict['F']):
answer += 'C'
else :
answer += 'F'
if(myDict['J'] >= myDict['M']):
answer += 'J'
else :
answer += 'M'
if(myDict['A'] >= myDict['N']):
answer += 'A'
else :
answer += 'N'
return answer
LIST