for a, b in enumerate(privacies):
print(a, b)
enumerate 활용해서 index를 answer에 추가하는 미친 생각은 뭘까? ㅋㅋ..대단
# day(일자) 즉, 최소 단위로 모두 변환 (이게 KEY POINT !!)
def to_days(date):
year, month, day = map(int, date.split("."))
return year * 28 * 12 + month * 28 + day
def solution(today, terms, privacies):
months = {v[0]: int(v[2:]) * 28 for v in terms}
today = to_days(today)
expire = [
i + 1 for i, privacy in enumerate(privacies)
if to_days(privacy[:-2]) + months[privacy[-1]] <= today
]
return expire
최소 단위로 모두 바꿀 생각을 왜 못했을까~~~?
월로 주어져서 월로 하면 편할 줄 알았는데, 시행착오 겪자마자 다른 단위로 구해야 함을 알았다면...
생각보다 시간이 오래걸려서 답을 맞춰서 당황했는데, 이렇게 간단한 코드로 구현했다니 ... SHIT