개인정보 수집 유효기간
HOW
발상
- 오늘의 날짜를 일 수로 환산한다.
- 보관 시작 날짜부터 유효기간 까지를 일 수로 계산해 합산한 보관 가능 날짜를 구한다.
- 오늘 날짜와 보관 가능 날짜를 비교해 파기해야하는 개인정보를 정답 배열에 넣는다.
add
- 만약 2023년이라면 올 해는 아직 지나지 않았기 때문에 일 수로 환산할 때 (year - 1) * 336 을 해야 한다. 같은 원리로 month 와 day도 1씩을 빼준 뒤 계산한다.
솔루션 코드
def solution(today, terms, privacies):
answer = []
temp_terms = {}
for i in terms:
a, b = i.split()[0], int(i.split()[1])
temp_terms[a] = b
t_year = int(today[0:4])
t_month = int(today[5:7])
t_day = int(today[8:10])
today_date = ((t_year-1) * 336) + ((t_month-1) * 28) + (t_day-1)
for j in range(len(privacies)) :
temp = privacies[j].split()
year = int(temp[0][0:4])
month = int(temp[0][5:7])
day = int(temp[0][8:10])
option = temp[1]
total_date = ((year-1) * 336) + ((month-1) * 28) + (day-1)
limit_date = total_date + temp_terms[option] * 28 - 1
if(limit_date < today_date) :
answer.append(j+1)
return (answer)