Skip to content
DeepForgeby svx
All problems

Reward Clipping

Problem

Clip every reward into [-clip_value, clip_value]. An empty list returns [].

Hint

Clipping keeps large rewards from dominating the value targets.

Test cases

case 1
in: [[0.5,2,-3],1]
expected: [0.5,1,-1]
case 2
in: [[5,-5],2]
expected: [2,-2]
case 3
in: [[],1]
expected: []
Starter codePython
def clip_rewards(rewards, clip_value):
    # Your code here
    pass

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