Skip to content
DeepForgeby svx
All problems

Safety Cost Budget

Problem

Summarize safety cost usage: return [total_cost, remaining_budget, within_budget], where remaining = budget - total_cost and within_budget is True when remaining >= 0.

Hint

Negative remaining budget means the policy violated its cost constraint.

Test cases

case 1
in: [[0.1,0.2,0.3],1]
expected: [0.6000000000000001,0.3999999999999999,true]
case 2
in: [[2,3],4]
expected: [5,-1,false]
case 3
in: [[],1]
expected: [0,1,true]
Starter codePython
def safety_cost_budget(costs, budget):
    # Your code here
    pass

3 test cases · run your code against them in the editor