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

      Best question to ask

      A forager sorts a basket of mushrooms with one yes/no question about each, like “Does it have a ring on the stem?”. The answer sorts the basket into left (yes) and right (no), each a list of labels: "toxic" or "safe". Before the question, telling whether a random mushroom is toxic takes some yes/no questions on average (“How surprising?”); once you know its side, it may take fewer. Write split_score(left, right): how many yes/no questions the question saved, on average. Count them in bits, as in “How surprising?”: one bit is one yes/no question.

      Eight mushrooms, four of them toxic. The forager asks “Does it have a ring on the stem?”, and each mushroom goes left (yes) or right (no). Your function says how many yes/no questions that saved, on average.

      one question, one basket of mushrooms8 mushroomstoxicsafe to eatDoes it have a ring on the stem?yes: left3 toxic, 1 safeno: right1 toxic, 3 safequestions saved, on average?

      how many questions did it save? that’s for you to work out

      Your functionsplit_score(left, right)
      leftthe labels ("toxic" or "safe") on each sidee.g. ["toxic", "safe"]
      rightthe labels ("toxic" or "safe") on each sidee.g. ["toxic", "safe", "toxic", "safe"]
      returnshow many yes/no questions the split saved, on average
      solution.pyLoading Python
      Sign in for an AI hint
      ← How surprising?Planning for the wrong world →