Drill

ProblemsJava › logistics

When does the order actually arrive

mediumlogisticsMathSimulationJava

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.

deliveryEta(processingDays: int) → int

Java needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

int deliveryEta(int processingDays) {
    
}

Worked examples

CallResult
deliveryEta(1)1
deliveryEta(2)2
deliveryEta(5)7
deliveryEta(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 Java
int deliveryEta(int processingDays) {
    int day = 1, done = 0;
    while (done < processingDays) {
        if (day % 7 < 5) done++;
        if (done < processingDays) day++;
    }
    return day;
}

The same problem in another language

More logistics problems in Java