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

      Fix the colors

      A colour photo is a grid of pixels, each three numbers from 0 to 255: how much red, green and blue light it caught. Under an orange street lamp everything comes out orange: your eyes adjust and still see white snow, the camera doesn’t. Write fix(photo): take the light’s colour out of the photo and keep it as bright as it was. You aren’t told what the light was: all you have is the photo.

      A snowman at night, as your eyes see it and as the camera sees it under an orange street lamp. The lamp changes each colour by its own amount, so taking the same orange off every pixel turns black blue. The goal is the photo it ends on. Your fix(photo) gets only the camera’s photo.

      A snowman at night. Your eyes see white snow, a grey wall, a black hat.as your eyes see it
      Your functionfix(photo)
      photothe camera's photo, a numpy array of shape (13, 16, 3): each pixel's red, green and blue, from 0 to 255 photo[y, x] is one pixel, photo[:, :, 0] all the redse.g. [[[90, 76, 52], [90, 76, 52], [90, 76, 52]…
      returnsthe photo with the light's colour taken out, as bright as it was, the same shape
      solution.pyLoading Python
      Sign in for an AI hint
      ← Zoom inDid it see the ear? →