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 130

      Collect them all

      Every cereal box hides one toy from a set of toys, each toy as likely as any other, and you have have different ones so far. Write expected_boxes(toys, have): how many more boxes you’ll buy, on average, before you have the whole set.

      A set of 6 toys, one in every cereal box, and a collector opening boxes: amber for a new toy, hollow for a repeat. Six toys, six boxes? Not even close, and the last toy alone takes a long wait. 100 collectors’ waits for each new toy rise to the last. The goal is the average number of boxes, from any start.

      Every cereal box hides one of 6 toys, each as likely. Collect all 6.the set: 6 toys123456boxes opened: 0100 collectors: average wait1st new toy → last
      Your functionexpected_boxes(toys, have)
      toyshow many different toys the set has, each as likely to be in a boxe.g. 1
      havehow many different toys you have so fare.g. 0
      returnshow many more boxes you'll buy, on average, to complete the set
      solution.pyLoading Python
      Sign in for an AI hint
      ← How many tables stay empty?Switch or stay? →