Drill

ProblemsGo › logistics

When does the order actually arrive

mediumlogisticsMathSimulationGo

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

Go 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

func deliveryEta(processingDays int) int {
	
}

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 Go
func deliveryEta(processingDays int) int {
	day, done := 1, 0
	for done < processingDays {
		if day%7 < 5 {
			done++
		}
		if done < processingDays {
			day++
		}
	}
	return day
}

The same problem in another language

More logistics problems in Go