Programmers
[프로그래머스 / 파이썬 풀이] 개인정보 수집 유효기간
Hoo_Dev
2023. 1. 25. 11:03
def solution(today, terms, privacies):
answer = []
y, m, d = today.split('.')
today_to_day = int(y) * 12 * 28 + int(m) * 28 + int(d)
terms_dic = {}
for i in terms:
a = i.split(" ")
terms_dic[a[0]] = int(a[1]) * 28
for i in range(len(privacies)):
first = privacies[i].split(" ")
second = first[0].split('.')
change_day = int(second[0]) * 12 * 28 + int(second[1]) * 28 + int(second[2]) + terms_dic[first[1]]
if today_to_day >= change_day:
answer.append(i+1)
return answer
각 일자를 일 수로 변환하여 풀이한다. (주의 할 점은 한 달은 28일로 고정.)
딕셔너리를 통해 해당 약관 기간 또한 일수로 변환하여 더해준 후 비교