코테 준비/프로그래머스
[level 1] 개인정보 수집 유효기간
쿠쿠*_*
2023. 5. 9. 22:29
https://school.programmers.co.kr/learn/courses/30/lessons/150370
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
핵심포인트
✅dict()구조를 사용해서 terms을 새롭게 정의
✅split()을 사용해서 제대로 p_year, p_month, p_day를 구분하고 더하는것이 필요하다. 주어진 조건을 모두 만족할 수 있도록 체크해야함
def solution(today, terms, privacies):
answer = []
time_dict=dict()
year,month,day=int(today[0:4]),int(today[5:7]),int(today[8:])
for term in terms:
case=term[0]
time_dict[case]=int(term[2:])
for i in range(len(privacies)):
date, case = privacies[i].split()
p_year, p_month, p_day = int(date[0:4]), int(date[5:7]), int(date[8:10])
p_month += time_dict[case]
# if p_month > 12 : print(p_year,p_month, p_day, case)
while p_month > 12 :
p_month -= 12
p_year +=1
if p_year > year :
continue
elif p_year == year :
if p_month > month :
continue
elif p_month == month :
if p_day > day :
continue
answer.append(i+1)
# 배열사용을 위해 i는 0부터 시작하므로 정답에 +1 하여 추가합니다
# print(p_year,p_month,p_day,case)
return answer