When does the order actually arrive
Fulfilment ships on business days only — Saturday and Sunday never move a parcel. Estimate the calendar day an order placed on day 0 reaches the door after processingDays of travel.
- Day 0 is a Monday, and the parcel sets off the next business day.
- One business day (Mon–Fri) is consumed per day of travel; weekends do not count.
- Return the calendar day, counted from day 0, on which the last travel day ends.
- processingDays of zero still ships on the next business day.
delivery_eta(processing_days: int) → int
Where you start
def delivery_eta(processing_days: int) -> int:
Worked examples
| Call | Result |
|---|---|
delivery_eta(1) | 1 |
delivery_eta(2) | 2 |
delivery_eta(5) | 7 |
delivery_eta(6) | 8 |
Hint
Walk day by day; each business day consumed advances the done count, and only stop once it matches processingDays.
Reference solution in Python
def delivery_eta(processing_days: int) -> int:
day, done = 1, 0
while done < processing_days:
if day % 7 < 5:
done += 1
if done < processing_days:
day += 1
return day