문제 설명 및 제한사항
아이디어 및 해결 방법
코드
from collections import Counter
def result(scores):
l = []
l.append('R' if scores['R'] >= scores['T'] else 'T')
l.append('C' if scores['C'] >= scores['F'] else 'F')
l.append('J' if scores['J'] >= scores['M'] else 'M')
l.append('A' if scores['A'] >= scores['N'] else 'N')
return ''.join(l)
def solution(survey, choices):
scores = Counter()
for surv, choi in zip(survey, choices):
if choi == 1:
scores[surv[0]] += 3
elif choi == 2:
scores[surv[0]] += 2
elif choi == 3:
scores[surv[0]] += 1
elif choi == 5:
scores[surv[1]] += 1
elif choi == 6:
scores[surv[1]] += 2
elif choi == 7:
scores[surv[1]] += 3
return result(scores)
Python
복사
출처
프로그래머스 코딩테스트 연습 https://school.programmers.co.kr/learn/challenges