Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      92 of 102

      A reward now or later

      A move in a game brings rewards over the coming steps. A reward you get one step later is worth patience (between 0 and 1) of the same reward right now: you have to wait for it, and things can go wrong on the way. Write worth(rewards, patience): what the whole list of rewards is worth right now.

      A move pays 10, two steps from now, with patience 0.9: a reward one step later is worth 0.9 of the same reward now. Carry it back to right now and drop it in the jar. What is the jar worth?

      A move in a game, and the steps that follow it.now+1× 0.9+2× 0.9pays 10each step of waiting: a reward is worth 0.9 of what it would be a step soonerworth right now?worth([0, 0, 10], patience 0.9) → ?
      Your functionworth(rewards, patience)
      rewardsthe reward at each coming step, starting with right nowe.g. [5]
      patiencewhat a reward one step later is worth, as a share of the same reward now (0 to 1)e.g. 0.9
      returnswhat the whole list is worth right now
      solution.pyLoading Python
      Sign in for an AI hint
      ← A small change to a big matrixDon’t wait for the end →