관리 메뉴

솜씨좋은장씨

[Programmers] 2022 KAKAO TECH INTERNSHIP - 성격 유형 검사하기 (Python) 본문

Programming/코딩 1일 1문제

[Programmers] 2022 KAKAO TECH INTERNSHIP - 성격 유형 검사하기 (Python)

솜씨좋은장씨 2022. 8. 30. 12:47
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 프로그래머스의 2022 KAKAO TECH INTERNSHIP 성격 유형 검사 하기 입니다.

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

👨🏻‍💻 코드 ( Solution )

def get_character_score(question, choice, score_list):
    if 1 <= choice <= 4:
        character_type = question[0]
        score = score_list[choice-1]
    elif 5 <= choice <= 7:
        character_type = question[1]
        score = score_list[choice-1]
        
    return character_type, score


def get_high_score_character(score_dict, character1, character2):
    if score_dict[character1] > score_dict[character2]:
        high_score_character = character1
    elif score_dict[character1] < score_dict[character2]:
        high_score_character = character2
    else:
        high_score_character = min(character1, character2)
        
    return high_score_character


def make_character_type_string(score_dict):
    character_type_string = ""
    character_list = [
        ("R", "T"), ("C", "F"), ("J", "M"), ("A", "N")
    ]
    
    for character in character_list:
        high_score_character = get_high_score_character(
            score_dict=score_dict, 
            character1=character[0], character2=character[1]
        )
        character_type_string += high_score_character
        
    return character_type_string


def solution(survey, choices):
    character_type_score_dict = {
        "R": 0, "T": 0, "C": 0, "F": 0,
        "J": 0, "M": 0, "A": 0, "N": 0
    }
    score_list = [3, 2, 1, 0, 1, 2, 3]
    
    for question, choice in zip(survey, choices):
        character_type, score = get_character_score(
            question=question, choice=choice, score_list=score_list
        )
        
        character_type_score_dict[character_type] += score
        
    return make_character_type_string(score_dict=character_type_score_dict)
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments