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

      The ball keeps rolling

      A ball rolls down the foggy hill from “Walk downhill”. Unlike the careful walker, it carries some of its motion from one step to the next. Write roll(state, slope, step_size, keep): the ball’s new state. state is [position, velocity], where the velocity is how far the ball moved on its last step (negative means to the left). Each step the slope pushes the ball downhill, and keep (0 to 1) is how much of its motion the ball keeps.

      The hill from “Walk downhill”, fog lifted. A careful walker takes plain steps, step_size × slope, and stops dead where the ground goes flat. A ball keeps some of its motion from one step to the next. Watch both go down, then write the ball’s step.

      The hill, fog lifted: a long slope, a flat shelf, then the real bottom.a flat shelfthe bottomthe walker: plain stepsthe ball: keeps 0.85?roll([3, −0.4], 2, 0.1, 0.9) →
      Your functionroll(state, slope, step_size, keep)
      state[position, velocity], velocity = how far it moved last stepe.g. [3, 0]
      slopehow steeply the ground rises to the right heree.g. 6
      step_sizehow hard the slope pushes the ball each stepe.g. 0.1
      keep0 to 1, how much of its motion the ball keepse.g. 0
      returnsthe new [position, velocity]
      solution.pyLoading Python
      Sign in for an AI hint
      ← Smooth the noiseOne step size per direction →