-
프로그래머스(Programmers) LEVEL1 - 성격유형검사하기Algorithm/Problems_Solving 2022. 10. 9. 12:24
scores = {1:3, 2:2, 3:1, 4:0, 5:1, 6:2, 7:3} answer_report = {1: {"R":0, "T":0}, 2 :{"C":0, "F":0}, 3: {"J":0, "M":0}, 4: {"A":0, "N":0}, } def organization(answer): answer = {k : dict(sorted(v.items(), key=lambda x:(-x[1], x[0]))) for k, v in answer.items()} return "".join([list(v.keys())[0] for k, v in answer.items()]) def added_score(answer, result:dict) -> dict: for k, v in answer.items(): for type, score in result.items(): if type in v: v[type] = score return organization(answer) def solution(survey, choices): result = {} for type, choice in zip(survey, choices): if choice in range(1,4): # 비동일 경우 첫번째 result[type[0]] = scores[choice] elif choice in range(5,8): # 동의일 경우 두번째 result[type[1]] = scores[choice] return added_score(answer=answer_report,result=result) 정확성: 35.0 합계: 35.0 / 100.0
틀렸던 테스트 케이스를 찾아보니까(?) 같은 유형이 의 점수가 2번이상 나올 수 있다고 함
예를 들어 A 유형이 2번 나오면 (3점, 1점), 4점이 되어야 하는데 위와 같이 하면은 두번째 나왔던 1점이 됨
'Algorithm > Problems_Solving' 카테고리의 다른 글
백준(BaekJoon) - 2501 약수구하기 (0) 2022.10.10 백준(BaekJoon) 1924번 - 2007년 (0) 2022.10.10 프로그래머스(Programmers) LEVEL2 - 전화번호 목록 (0) 2022.10.03 프로그래머스(Programmers) LEVEL2 - 위장 (0) 2022.10.02 프로그래머스(Programmers) LEVEL2 - JadenCase 문자열 만들기 (0) 2022.10.02