https://school.programmers.co.kr/learn/courses/30/lessons/118666
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
2022 카카오 인턴 채용에 사용된 코딩테스트 문제였습니다.
간단하게 조건에 따라 점수를 더해주고 그 점수로 문자열만 만들어주면 끝나는 구현문제였습니다.
def solution(survey, choices):
typedict = {'R': 0, 'T': 1, 'C': 2, 'F': 3, 'J': 4, 'M': 5, 'A': 6, 'N': 7}
point = [0, 0, 0, 0, 0, 0, 0, 0]
answer = ''
for i in range(len(survey)):
positive = typedict[survey[i][1]]
negative = typedict[survey[i][0]]
if choices[i] < 4:
point[negative] += 4 - choices[i]
elif choices[i] > 4:
point[positive] += choices[i] - 4
if point[0] < point[1]:
answer += 'T'
else:
answer += 'R'
if point[2] < point[3]:
answer += 'F'
else:
answer += 'C'
if point[4] < point[5]:
answer += 'M'
else:
answer += 'J'
if point[6] < point[7]:
answer += 'N'
else:
answer += 'A'
return answer
728x90
'🔍 알고리즘 > 프로그래머스 Python' 카테고리의 다른 글
[Python] 프로그래머스 12944. 평균 구하기 (Lv.1) (0) | 2022.09.27 |
---|---|
[Python] 프로그래머스 118667. 두큐합같게만들기 (Lv.2) (0) | 2022.08.23 |
[Python] 프로그래머스 42586. 기능개발 (Lv.2) (0) | 2022.08.17 |
[Python] 프로그래머스 12899. 124 나라의 숫자 (Lv.2) (0) | 2022.08.17 |
[Python] 프로그래머스 12906. 같은 숫자는 싫어 (Lv.1) (0) | 2022.08.17 |