Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
without branch solution in Creative category for The First Working Day by Sim0000
from datetime import datetime as dt, timedelta
def vacation(date, days):
day = dt.strptime(date, '%Y-%m-%d') + timedelta(days)
d = day.weekday()
return (day + timedelta((d > 4) + (d == 5))).strftime('%Y-%m-%d')
if __name__ == '__main__':
print("Example:")
print(vacation('2018-07-01', 14))
#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!")
Oct. 19, 2018