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
      53 of 130

      Which coin did they flip?

      A street magician has a tray of trick coins, each stamped with how often it lands heads. Behind a screen he flips one of them and shows you every flip. Write most_likely_coin(flips, coins): return the position on the tray of the coin most likely to have thrown exactly these flips(0 for the first coin).

      The magician flipped one of two coins 50 times: 31 heads. The obvious pick is the coin closest to 62% heads, the 90% coin. Then follow each coin’s chance of throwing exactly these flips, one flip at a time: every tail costs the 90% coin dearly. The goal is the coin whose chance ends highest. Your most_likely_coin() picks it.

      The magician flipped one of these coins 50 times. Which one?flips31 heads19 tails62% headschance of throwing these flips so far11 in 10⁵1 in 10¹⁰1 in 10¹⁵1 in 10²⁰1 in 10²⁵startflip 5030% coin90% coin
      Your functionmost_likely_coin(flips, coins)
      flipswhat the magician threw, in order: 1 = heads, 0 = tails (a list)e.g. [1, 1, 1, 1, 1, 1, 1, 1]
      coinseach coin's chance of landing heads, e.g. [0.3, 0.9] (a list)e.g. [0.5, 0.9, 0.2]
      returnsthe position in coins of the coin most likely to have thrown these flips, e.g. 0
      solution.pyLoading Python
      Sign in for an AI hint
      ← Two cluesTwo for two →