[프로그래머스]개인정보 수집 유효기간

Effy_ee·2023년 9월 19일
0

코딩테스트

목록 보기
52/118

(Lv.01) 개인정보 수집 유효기간👾
https://school.programmers.co.kr/learn/courses/30/lessons/150370

💻 답안

def calc_date(today):
    year,month,date=map(int,today.split("."))
    return year*12*28+month*28+date

def solution(today,terms,privacies):
    answer=[]
    today_date=calc_date(today)
    term_map={term[0]:int(term[2:]) for term in terms}
    
    for index, privacy in enumerate(privacies):
        expire=term_map[privacy[-1]]
        date=calc_date(privacy[:-2])+expire*28
        if date<=today_date:
            answer.append(index+1)
    return answer

0개의 댓글