본문 바로가기
코딩테스트 파이썬/파이썬 프로그래머스 1단계

개인정보 수집 유효기간

by 세용용용용 2023. 5. 22.

나의 코드

#날짜를 일로 바꾸는 코드
def total_day(date):
    year, month, day = map(int, date.split('.'))
    return (year*12*28)+(month*28)+day

def solution(today, terms, privacies):
    today_day = total_day(today)
    answer = []
    dic_terms = {}
    count = 1
    for i in terms:
        dic_terms[i[0]] = int(i.split(' ')[-1])
   
    for i in privacies:
        i_split = i.split(' ')
        privacies_date = i_split[0]
        term_date = dic_terms[i_split[-1]]

        privacies_day = total_day(privacies_date)+(term_date*28)-1
        print(today_day)
        print(privacies_day)
        if today_day > privacies_day:
            answer.append(count)
       
        count += 1
   
    print(answer)
    return answer

solution("2022.05.19", ["A 6", "B 12", "C 3"],
         ["2021.05.02 A",
          "2021.07.01 B",
          "2022.02.19 C",
          "2022.02.20 C"] )

'코딩테스트 파이썬 > 파이썬 프로그래머스 1단계' 카테고리의 다른 글

신고 결과 받기  (0) 2023.05.22
바탕화면 정리  (0) 2023.05.22
성격 유형 검사하기  (0) 2023.05.22
햄버거 만들기  (0) 2023.05.22
둘만의 암호  (0) 2023.05.22