https://school.programmers.co.kr/learn/courses/30/lessons/118666
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
def solution(survey, choices):
answer = ''
type = ['RT','TR','CF','FC','JM','MJ','AN','NA']
score = [[0,0] for _ in range(8)]
for i in range(len(survey)):
type_idx = type.index(survey[i])
if choices[i] <= 3:
score[type_idx][0] += 4 - choices[i]
elif choices[i] >= 5:
score[type_idx][1] += choices[i] - 4
final_score = [[0,0] for _ in range(4)]
type2 = ['RT','CF','JM','AN']
for i in range(4):
final_score[i][0] = score[i*2][0] + score[i*2+1][1]
final_score[i][1] = score[i*2][1] + score[i*2+1][0]
for i in range(4):
if final_score[i][0] > final_score[i][1]:
answer += type2[i][0]
elif final_score[i][0] < final_score[i][1]:
answer += type2[i][1]
else:
if i == 0:
answer += 'R'
elif i == 1:
answer += 'C'
elif i == 2:
answer += 'J'
else:
answer += 'A'
return answer
'프로그래머스' 카테고리의 다른 글
프로그래머스 92341. 주차 요금 계산 (0) | 2023.11.09 |
---|---|
프로그래머스 72413. 합승 택시 요금 (0) | 2023.11.08 |
프로그래머스 42898. 등굣길 (0) | 2023.11.07 |
프로그래머스 42883. 큰 수 만들기 (0) | 2023.11.02 |
86971. 전력망을 둘로 나누기 (0) | 2023.10.31 |