Skip to content
DeepForgeby svx
All problems

Safety Shield Override

Problem

Override an unsafe action with the safest available one.

If predicted_costs[action] <= threshold return the action unchanged; otherwise return the index of the minimum predicted cost (smallest index on ties).

Hint

The shield is a runtime filter that guarantees the executed action is safe.

Test cases

case 1
in: [2,[0.1,0.5,1],0.8]
expected: 0
case 2
in: [1,[0.1,0.5,1],0.8]
expected: 1
case 3
in: [2,[0.5,0.2,0.9],0.7]
expected: 1
Starter codePython
def safety_shield_override(action, predicted_costs, threshold):
    # Your code here
    pass

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