프로그래머스 - 성격 유형 검사하기
문제집 링크 : http://aladin.kr/p/szPra
프로그래머스 URL :
■ 작성 코드
from collections import defaultdict
def solution(survey, choices):
ans = defaultdict(int)
for t, choice in zip(survey, choices):
if choice < 4:
ans[t[0]] += 4 - choice
else:
ans[t[1]] += choice - 4
answer = ""
for t1, t2 in ("RT", "CF", "JM","AN"):
if ans[t1] >= ans[t2]:
answer += t1
else:
answer += t2
return answer
반응형
'Programming Test > 문제풀이' 카테고리의 다른 글
[프로그래머스] 26. 숫자 문자열과 영단어 - Python (0) | 2025.01.31 |
---|---|
[프로그래머스] 25. 가장 가까운 글자 - Python (0) | 2025.01.31 |
[프로그래머스] 23. 로그인 성공? - Python (0) | 2025.01.28 |
[프로그래머스] 22. 바탕화면 정리 - Python (0) | 2025.01.27 |
[프로그래머스] 21. 행렬의 덧셈 - Python (0) | 2025.01.25 |