[Programmers] 개인정보 수집 유효기간

yewon Lee·2023년 3월 14일
1

해결방법: 년, 월, 일을 일 수로 변경

def solution(today, terms, privacies):
    
    tY, tM, tD = map(int,today.split('.'))
    todayD = tY*12*28 + tM*28 + tD
    
    ttype = []
    tterm = []
    
    for i in terms:
        tType, tTerm = i.split(' ')
        tTerm = int(tTerm)*28
        ttype.append(tType)
        tterm.append(tTerm)
        
    answer = []
    
    i = 1
    
    for p in privacies:
        pDate, pType  = p.split(' ') #pDate는 수집일자, pType는 약관종류
        pY, pM, pD = map(int,pDate.split('.'))
        privaciesD = pY*12*28 + pM*28 + pD

        n = ttype.index(pType)
        v = tterm[n]
        
        expirationD = privaciesD + v
        
        if todayD >= expirationD:
            answer.append(i)
            
        i = i+1
        
    return answer
    

문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/150370?language=python3

profile
시작

0개의 댓글