https://school.programmers.co.kr/learn/courses/30/lessons/150370
f"{term_year}.{term_month:0>2}.{day:0>2}"term_year=2000, term_month=1, day=12 라고 한다면, "2000.01.12"라는 문자열을 만드는 역할을 한다.{변수:0>길이값} : 변수에 대해서 중앙 정렬이 아닌 (>)오른쪽으로 정렬을 해주는데, 폭을 길이값으로 하고, 부족한 부분은 0으로 채워넣는다는 의미python
# 개인정보 n개 (고객의 약관 동의를 얻어 수집됨)
# 약관 종류 다양, 각 약관별 보관 유효기간 따로따로 정해져 있음
def solution(today, terms, privacies):
year, month, day = map(int, today.split("."))
day += 1
expiration_date = {}
for term in terms:
term_type, term_month = term.split()
term_month = int(term_month)
if day == 29:
term_month += 1
term_month = month - term_month
term_year = year
if term_month <= 0:
term_year -= -term_month // 12 + 1
term_month = 12 - (-term_month % 12)
expiration_date[term_type] = f"{term_year}.{term_month:0>2}.{day:0>2}"
# 파기해야 할 개인정보
result = []
for idx, privacy in enumerate(privacies):
regist_date, regist_term = privacy.split()
if regist_date < expiration_date[regist_term]:
result.append(idx + 1)
return result
if __name__ == "__main__":
result = solution(
today="2020.05.17",
terms=["A 3", "B 12"],
privacies=["2020.01.01 A", "2020.05.16 B"],
)
print(result)
[1]