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
      54 of 102

      Walk downhill

      You’re on a hill in thick fog, trying to reach the bottom. You can’t see it; you can only feel the slope under your feet: how steeply the ground rises as you go right (negative means it rises to the left). Write step(position, slope, step_size): where your next step should land.

      You stand at position 3 on a hill hidden in fog, trying to reach the bottom. All you can feel is the ground under your feet. Walk it yourself, then write the function that decides each step.

      Thick fog. Somewhere below is the bottom of the valley.fog: the hill is hidden; you only feel the ground under your feet−4−3−2−101234positionslope 6: rises to the rightstep(position 3, slope 6, step_size 0.1): where should the next step land??
      Your functionstep(position, slope, step_size)
      positionwhere you stand, a number on a linee.g. 5
      slopehow steeply the ground rises to the right heree.g. 0
      step_sizehow bold your steps aree.g. 0.1
      returnswhere your next step should land
      solution.pyLoading Python
      Sign in for an AI hint
      ← How wrong is the forecast?Through the cloud →