2023 KAKAO BLIND RECRUITMENT - 150370. 개인정보 수집 유효기간
[Lv. 1]
https://school.programmers.co.kr/learn/courses/30/lessons/150370
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이
딱히 설명할 부분은 없는 Lv. 1 문제.
String Slicing과,
유효기간
은 개인정보를 보관할 수 있는 달 수를 나타내는 정수이며, 1 이상 100 이하입니다.
라는 설명에 주의하며, month -= 12
, year += 1
을 만족할 때까지 반복해줘야 함에만 신경써주면 될 것.
def solution(today, terms, privacies):
answer = []
termList = {}
for t in terms:
termList[t.split()[0]] = int(t.split()[1])
privList = []
for p in privacies:
privList.append(p.split())
t_year = int(today[:4])
t_month = int(today[5:7])
t_day = int(today[8:10])
for index, p in enumerate(privList):
year = int(p[0][:4])
month = int(p[0][5:7])
day = int(p[0][8:10])
c = p[1]
# term에 따른 month 추가
m = termList[c]
month += m
while month >= 13:
month -= 12
year += 1
# 비교
if t_year > year:
answer.append(index+1)
continue
elif t_year == year:
if t_month > month:
answer.append(index+1)
continue
elif t_month == month:
if t_day >= day:
answer.append(index+1)
else:
continue
else:
continue
else:
continue
return answer