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

      The shadow

      Two arrows on a flat floor, each a list [across, up]. The direction marks a line through the start; light falls on it at a right angle, so every point of arrow drops straight onto that line. Write shadow(arrow, direction): how far the arrow’s shadow reaches along the direction. A shadow that falls backward, against the direction, counts as negative.

      An arrow 3 across and 4 up, and a direction along the floor’s edge. Light falls onto the direction’s line at a right angle. How far along the line does the shadow reach?

      arrow [3, 4]direction [1, 0]how long is the shadow??light falls at a right angleonto the dashed line
      Your functionshadow(arrow, direction)
      arrow[across, up], e.g. [3, 4] and [1, 0]e.g. [3, 0]
      direction[across, up], e.g. [3, 4] and [1, 0]e.g. [1, 0]
      returnshow far the arrow's shadow reaches along the direction
      solution.pyLoading Python
      Sign in for an AI hint
      ← Invent the scoreDo they move together? →