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
      89 of 114

      Find the patch

      A robot collects golf balls. It knows what a ball looks like in its camera: a small template, a bright dot on grass, 3 × 3 pixels. Write match(window, template): given a window of the photo the same size as the template, say how well it matches: the higher, the more it looks like the ball. The robot will go to the windows that score highest, so every ball should score high, wherever it lies.

      The robot’s photo of the driving range, each pixel a brightness drawn as its grey, and the ball it looks for. It slides the ball over the photo and scores every window, drawn under the photo as a score map. The brightest spot is the sand; comparing pixel by pixel loses the balls in the shadow and the mist. The goal is a map like the one it ends on. Your match(window, template) scores one window.

      A robot collects golf balls. This is its camera’s photo of the driving range.the photothe ball it looks for4848248484its 9 pixels, row by row
      Your functionmatch(window, template)
      windowa 3x3 patch of the photo (a numpy array), brightness 0 to 24e.g. [[4, 8, 4], [8, 24, 8], [4, 8, 4]]
      templatethe 3x3 ball the robot looks for (a numpy array), the same sizee.g. [[4, 8, 4], [8, 24, 8], [4, 8, 4]]
      returnshow well the window matches the template: the higher, the better
      solution.pyLoading Python
      Sign in for an AI hint
      ← One box per faceMerge the most common pair →