반응형
https://school.programmers.co.kr/learn/courses/30/lessons/118666#qna
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제풀이
from collections import defaultdict
def solution(survey, choices):
answer = []
# 각 지표는 이미 사전순으로 정리가 되어있음
tables = ["RT", "CF", "JM", "AN"]
scores = {1: 3, 2: 2, 3: 1, 5: 1, 6: 2, 7: 3}
types = defaultdict(int)
# 유형 점수계산
for i in range(len(survey)):
no, yes = survey[i][0], survey[i][1]
if choices[i] in [1, 2, 3]:
types[no] += scores[choices[i]]
elif choices[i] in [5, 6, 7]:
types[yes] += scores[choices[i]]
# 각 지표에서 점수가 높은 순으로 정리, 점수가 같다면 사전순으로 정리
for word in tables:
if types[word[0]] > types[word[1]] or types[word[0]] == types[word[1]]:
answer.append(word[0])
else:
answer.append(word[1])
return "".join(answer)
'프로그래머스 > lv.1' 카테고리의 다른 글
개인정보 수집 유효기간 (0) | 2024.01.30 |
---|---|
[PCCE 기출문제] 10번 / 데이터 분석 (0) | 2024.01.30 |
둘만의 암호 (0) | 2024.01.29 |
신규 아이디 추천 (0) | 2024.01.28 |
키패드 누르기 (0) | 2024.01.28 |