Drill

ProblemsPython › logistics

When does the order actually arrive

mediumlogisticsPython

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.

delivery_eta(processing_days: int) → int

Solve it in the editor →

Where you start

def delivery_eta(processing_days: int) -> int:
    

Worked examples

CallResult
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

The same problem in another language

More logistics problems in Python