유형 : 구현
풀이 시간 : 10분
이거 맞나? 구현.. 노가다..
def solution(survey, choices):
answer = []
survlist = [[survey[i][0], survey[i][1]] for i in range(len(survey))]
resdict = dict([[j, 0] for j in ['R', 'T', 'C', 'F', 'J', 'M', 'A', 'N']])
for i in range(len(choices)):
if choices[i] <= 3:
resdict[survlist[i][0]] += 4 - choices[i]
elif choices[i] >= 5:
resdict[survlist[i][1]] += choices[i] - 4
if resdict['R'] >= resdict['T']:
answer.append('R')
else:
answer.append('T')
if resdict['C'] >= resdict['F']:
answer.append('C')
else:
answer.append('F')
if resdict['J'] >= resdict['M']:
answer.append('J')
else:
answer.append('M')
if resdict['A'] >= resdict['N']:
answer.append('A')
else:
answer.append('N')
return ''.join(answer)
'프로그래머스 > Lv. 1' 카테고리의 다른 글
56. 신고 결과 받기 (0) | 2024.07.17 |
---|---|
55. 개인정보 수집 유효기간 ★ (0) | 2024.07.17 |
53. 신규 아이디 추천 ★ (isalpha, isdigit) (0) | 2024.07.17 |
52. 키패드 누르기 (0) | 2024.07.17 |
51. 크레인 인형뽑기 게임 (0) | 2024.07.16 |