All problems
Safety Stock Formula
Problem
Compute safety stock as z * sigma_demand * sqrt(lead_time), where z is the service-level multiplier and sigma_demand the demand standard deviation per period.
Return 0.0 for negative lead time.
Hint
Demand variance over the lead time grows linearly, hence the square root.
Test cases
case 1
in: [1.65,10,4]
expected: 33
case 2
in: [2,5,1]
expected: 10
case 3
in: [1.96,0,9]
expected: 0
case 4
in: [1.5,2,0]
expected: 0
Starter codePython
def safety_stock(z, sigma_demand, lead_time):
# Your code here
pass4 test cases · run your code against them in the editor