CS/Algorithm 문제
[Programmers] 성격 유형 검사하기 - Python
심심231
2022. 9. 18. 20:40
[Programmers] 성격 유형 검사하기 - Python
🎈문제
https://school.programmers.co.kr/learn/courses/30/lessons/118666
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
간단한 문자열 문제. 푸는데 10분정도 걸렸다.
👩💻코드
def solution(survey, choices):
answer = ""
tp = {"R": 0, "T": 0, "C": 0, "F": 0, "J": 0, "M": 0, "A": 0, "N": 0}
for i in range(len(survey)):
if choices[i] == 1:
tp[survey[i][0]] += 3
elif choices[i] == 2:
tp[survey[i][0]] += 2
elif choices[i] == 3:
tp[survey[i][0]] += 1
elif choices[i] == 5:
tp[survey[i][1]] += 1
elif choices[i] == 6:
tp[survey[i][1]] += 2
elif choices[i] == 7:
tp[survey[i][1]] += 3
answer += "R" if tp["R"] >= tp["T"] else "T"
answer += "C" if tp["C"] >= tp["F"] else "F"
answer += "J" if tp["J"] >= tp["M"] else "M"
answer += "A" if tp["A"] >= tp["N"] else "N"
return answer
728x90
반응형