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

      Switch or stay?

      A prize is behind one of doors doors, each as likely as the others, and you pick door 1. The host then opens opened of the other doors, and they’re all empty. Write chance_if_switch(doors, opened, host_knows): the chance you win if you switch to one particular other door that’s still closed. When host_knows is True he knows where the prize is and only ever opens empty doors; when it’s False he opened doors at random, and this time they just happened to be empty.

      Three doors, a prize behind one; you pick door 1 and the host, who knows where it is, opens an empty one. Two doors are left, so 50/50? 100 games say otherwise, and the bars over the doors count where the prize was. The goal is that chance for any number of doors, any doors opened, and either kind of host.

      Three doors, a prize behind one of them. You pick door 1.1yours2switch3host opened100 games, amber: switching wonswitching won 67 of 100
      Your functionchance_if_switch(doors, opened, host_knows)
      doorshow many doors there are; the prize is behind one at random, and you picked door 1e.g. 3
      openedhow many of the other doors the host opened, all of them emptye.g. 1
      host_knowsTrue if the host knows where the prize is (he only opens empty doors), False if he opened doors at random and they happened to be emptye.g. True
      returnsthe chance you win if you switch to one particular other door that's still closed
      solution.pyLoading Python
      Sign in for an AI hint
      ← Collect them allHow many heads? →