All problems
Horizon-Based Decay Weight
Problem
Build normalized horizon weights that decay geometrically: start from decay^h for h = 1, ..., horizon and divide each by their total so the weights sum to 1.
Return an empty list when horizon is not positive or all raw weights are zero.
Hint
Weights shrink as the horizon grows when decay is between 0 and 1.
Test cases
case 1
in: [3,0.5]
expected: [0.5714285714285714,0.2857142857142857,0.14285714285714285]
case 2
in: [1,0.9]
expected: [1]
case 3
in: [4,1]
expected: [0.25,0.25,0.25,0.25]
case 4
in: [0,0.5]
expected: []
Starter codePython
def horizon_decay_weights(horizon, decay):
# Your code here
pass4 test cases · run your code against them in the editor