Business-Day Arithmetic

easy
Unit 9 · State Machines0/3 to milestone

"Delivery in 3 business days" and "payment due in 30 working days" need business-day arithmetic. With ISO date strings and a set of holiday date strings, implement:

  • is_business_day(d, holidays=()): Monday to Friday, and not a holiday
  • business_days_between(start, end, holidays=()): the number of business days in [start, end). It's negative if end is before start.
  • add_business_days(start, n, holidays=()): the date n business days after start (or before, for negative n). Step one day at a time, counting only business days. n = 0 returns start if it's a business day, otherwise the next business day.
#dates#datetime#scheduling2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Business-Day Arithmetic · TechGradify