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

      Try the unknown

      A row of slot machines, each paying 1 (a win) or 0 per play. You know each machine’s average_wins so far, how many plays it has had, and total_plays across all of them. Write pick_machine(average_wins, plays, total_plays): which machine to play next, as its position (0 for the first), so that over many plays you win as much as you can.

      Machine A has paid 0.6 a play over 100 plays; machine B 0.5 over just 2. Play them yourself: is B really worse, or just barely tried?

      Aaverage a play00.510 playsBaverage a play00.510 playsclick a machine to play it once
      Your functionpick_machine(average_wins, plays, total_plays)
      average_winseach machine's average payout so far (0 if never played)e.g. [0.4, 0, 0.7]
      playshow many times each machine has been playede.g. [10, 0, 20]
      total_playsall plays so fare.g. 30
      returnsthe position of the machine to play next (0 = the first)
      solution.pyLoading Python
      Sign in for an AI hint
      ← Don’t wait for the endAsk the wrong crowd →