PIXELBANKv9.1.0
Menu

Undiscounted Finite-Horizon Return

Problem Statement

Compute the undiscounted return of an episode: the plain sum of all rewards collected, i.e. the discounted return with gamma = 1.

G0=∑t=1TRtG_0 = \sum_{t=1}^{T} R_t

Implement undiscounted_return(rewards) returning a Python float.

Example:

Input:
undiscounted_return([1.0, 2.0, 3.0])
Output:
6.0
Reasoning:
  • Identify the sequence of rewards collected during the episode from the input: R1=1.0R_1 = 1.0, R2=2.0R_2 = 2.0, and R3=3.0R_3 = 3.0.
  • Compute the undiscounted return by summing these rewards, as the discount factor γ=1\gamma = 1 implies no decay in value over time: G0=1.0+2.0+3.0G_0 = 1.0 + 2.0 + 3.0.
  • Perform the arithmetic addition to find the total accumulated reward: G0=6.0G_0 = 6.0.
  • The final output is 6.0

Constraints:

  • 0 <= len(rewards) <= 10000
  • Rewards may be negative or fractional.
  • An empty reward list returns 0.0.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Undiscounted Finite-Horizon Return - Easy | PixelBank