본문 바로가기
코딩테스트/Python

프로그래머스 스쿨 - 개인정보 수집 유효기간(Python)(복습)

by 보안매크로 2023. 10. 2.
728x90
today = "2022.05.19"
terms = ["A 6", "B 12", "C 3"]
privacies = ["2021.05.02 A", "2021.07.01 B", "2022.02.19 C", "2022.02.20 C"]

def time_convert(t) :
    year, month, day = map(int, t.split('.'))
    return year * 12 * 28 + month * 28 + day # 1달 28일

def solution(today, terms, privacies):
    term_dict = {}
    today = time_convert(today)
    answer = []    
   
    for term in terms :
        name, period = term.split()
        term_dict[name] = int(period) * 28
   
    for idx, privacy in enumerate(privacies) :
        start, name = privacy.split()
        end = time_convert(start) + term_dict[name]
        if end <= today :
            answer.append(idx+1)    
   
    return answer
728x90