Drill

ProblemsC# › inventory

When to reorder a part

easyinventoryMathC#

Purchasing wants the stock level at which a part should be reordered, so it arrives before the shelf runs dry.

ReorderPoint(dailyUse: int, leadDays: int, safety: int) → int

C# 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

public int ReorderPoint(int dailyUse, int leadDays, int safety) {
    
}

Worked examples

CallResult
ReorderPoint(10, 3, 5)35
ReorderPoint(0, 7, 20)20
ReorderPoint(12, 0, 0)0
ReorderPoint(-5, 3, 10)10

Hint

dailyUse × leadDays + safety, with each input floored at zero first.

Reference solution in C#
public int ReorderPoint(int dailyUse, int leadDays, int safety) {
    return Math.Max(0, dailyUse) * Math.Max(0, leadDays) + Math.Max(0, safety);
}

The same problem in another language

More inventory problems in C#