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
'BOJ' 카테고리의 다른 글
BOJ 백준 C++ 1759번 암호만들기 (1) | 2024.02.13 |
---|---|
2023 KAKAO BLIND RECRUITMENT : 개인정보 수집 유효기간 (0) | 2023.11.08 |
BOJ 1157번 단어공부 파이썬 (0) | 2022.03.17 |
백준 9012번 괄호 자바 풀이 (0) | 2022.01.19 |
BOJ 17608번 막대기 (0) | 2022.01.13 |