Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The First Working Day by Vlad_Lopato
from datetime import date
from datetime import timedelta
def vacation(date_iso, days):
last_day = date.fromisoformat(date_iso) + timedelta(days=days)
day = date.isoweekday(last_day)
return str(last_day + timedelta(days=7%day+1 if day in [6,7] else 0))
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert vacation('2018-07-01', 14) == '2018-07-16'
assert vacation('2018-02-19', 10) == '2018-03-01'
assert vacation('2000-02-28', 5) == '2000-03-06'
assert vacation('1999-12-20', 14) == '2000-01-03'
print("Coding complete? Click 'Check' to earn cool rewards!")
June 2, 2020