Problem 356526 · medium · Level 03 Linear Management & Searching

A Deadline in Working Days

py-modules · datetime · import · calendars

A council promises to answer letters within a number of working days: Monday to Friday, except public holidays. Write deadline(start, days, holidays) that returns the date that is days working days after the date start.

  • Dates are strings in the form "YYYY-MM-DD", and the result is too.
  • The start day itself never counts; the first working day after it is day 1. If days is 0, return start unchanged.
  • A negative days counts backwards in the same way (-1 is the last working day before start).
  • holidays is a list of date strings; those days are not working days.
  • An impossible date such as "2026-02-30" raises ValueError.

The helper raises(fn, *args) returns the name of the exception raised (or None).

Examples

Input:  deadline("2026-10-01", 3, [])
Output: "2026-10-06"
Explanation: 1 October 2026 is a Thursday. Friday is day 1, the weekend does not count,
             Monday is day 2 and Tuesday is day 3.

Input:  deadline("2026-12-23", 2, ["2026-12-25", "2026-12-28"])
Output: "2026-12-29"

Input:  raises(deadline, "2026-02-30", 1, [])
Output: "ValueError"

Constraints

  • -10**5 <= days <= 10**5; dates are between the years 1900 and 2500.
  • Up to 1000 holidays.

Goals

  • Use the standard library's `datetime` module instead of hand-written calendar arithmetic
  • Parse and format ISO dates, step by days with `timedelta`, and find the weekday
  • Let the library reject impossible dates
Starting Python…