On Instagram I saw a reel where Steve Ballmer, ex-CEO of Microsoft explained a game to an interviewer. I decided to see if it is a wining game or not. You can find the python code here

How the Game Works

Here’s what happens in the game:

  • A banker thinks of a number between 1 and 100
  • Your computer tries to guess it
  • If it guesses quickly, you win money
  • If it takes too many guesses, you lose money

The money part is simple: guess right on the first try, you get 5 euros. Second try? 4 euros. And so on. But watch out – after six tries, you start losing money to the bank!

The Algorithm

At the heart of this game lies a sophisticated algorithm that combines two key components:

  1. Binary Search Intelligence: They would always pick the middle number and then cut the possible answers in half. It’s like when you’re looking up a word in a dictionary – you open it in the middle, see if your word comes before or after that page, and then keep splitting the remaining pages in half until you find what you’re looking for.
  2. Controlled Randomness: Here’s where it gets fascinating. Instead of always choosing the mathematically perfect middle point, the algorithm adds a “wobble” to its guess. We sometimes go a little higher or lower than the perfect middle, just because it “feels right.” or because it is hard to calculate the average between two numbers fast. This wobble is controlled by what’s called a “distance factor” – a parameter that determines how far from the optimal guess the algorithm might stray.

Think of it as the difference between a robot and a human player. While a robot would always choose the mathematically perfect middle number, humans tend to add their own “noise” to their guesses. This simulation captures that human element through carefully calibrated random variations.

Too high, too low

How does this binary search work? Let me explain for you:

Step 1: Start in the Middle

Instead of guessing randomly, start by guessing the number right in the middle of the smallest and largest possible numbers. For example, if you know there are between 1 and 100, your first guess should be 50.

Step 2: Use the Hint

After you guess, listen to the hint:

  • If I say too high, you know the number must be less than 50, so you can forget about all numbers higher than 50.
  • If I say too low, the number must be more than 50, so you can forget about all numbers lower than 50.
  • If I say correct, you’ve won the game!

Step 3: Keep Splitting the Numbers

Each time, pick the middle number of the range that’s left:

  1. If I said your guess of 50 was too high, guess the middle of 1 to 49. That’s 25.
  2. If I said 25 was too low, guess the middle of 26 to 49. That’s 37.
  3. Keep going like this until you find the exact number.

The Science Behind the Randomness

Because it can be hard to calculate the average between two numbers fast, the game employs a normal distribution (also known as a Gaussian distribution) to generate its guesses. This creates a bell curve of possibilities centered around the mathematically optimal guess. The “distance factor” parameter controls how wide or narrow this bell curve becomes:

  • With a distance factor of 0, the game becomes purely deterministic – like a perfect robot. It takes the exact average between the last guess and the possible number.
  • As the distance factor increases, the guesses become more scattered, mimicking human imperfection
  • A tolerance zone ensures the guesses don’t stray too far from reasonableness

The Money Game

The way money works in this game is like a countdown:

  • Guess right first time: Win 5 euros
  • Second try: Win 4 euros
  • Third try: Win 3 euros
  • Fourth try: Win 2 euros
  • Fifth try: Win 1 euro
  • Sixth try: Nobody wins or loses
  • Seventh try: You pay 1 euro
  • Eight try: You pay 2 euro
  • etc. (you pay maximum 10 euro)

It’s like a game show where the prize gets smaller the longer you take – but wait too long, and you actually have to pay!n between speed and accuracy.

Maximum guesses

While the algorithm could theoretically use pure binary search to guarantee finding the number in at most 7 guesses (log₂100 ≈ 6.64), the introduction of randomness makes each game unique and unpredictable.

Let me explain why log₂100 tells us the maximum number of guesses needed in binary search!

Think about what happens each time we make a guess in binary search:

  1. We start with 100 possible numbers
  2. After first guess: 50 numbers left
  3. After second guess: 25 numbers left
  4. After third guess: 12-13 numbers left
  5. After fourth guess: 6-7 numbers left
  6. After fifth guess: 3-4 numbers left
  7. After sixth guess: 1-2 numbers left
  8. After seventh guess: Must be the number!

Do you notice something? Each guess cuts our search space in HALF. So we can write it like this:

  • 100 ÷ 2 = 50
  • 50 ÷ 2 = 25
  • 25 ÷ 2 ≈ 12.5
  • 12.5 ÷ 2 ≈ 6.25
  • 6.25 ÷ 2 ≈ 3.125
  • 3.125 ÷ 2 ≈ 1.56
  • 1.56 ÷ 2 < 1

The question “log₂100” is actually asking: “How many times do I need to divide 100 by 2 to get to 1?”

In math, we write this as: 100 = 2ˣ

  • Where x is the number of times we need to divide by 2
  • log₂100 ≈ 6.64 means we need between 6 and 7 divisions
  • Since we can’t make a partial guess, we round up to 7

That’s why binary search will always find the number in at most 7 guesses – because it takes 7 divisions by 2 to get from 100 down to 1!

Results

Here are the outcomes when you follow the algorithm and round down or up if the possible guess is a half number (for example 100+1 = 50,5). The last column contains bank wins when the player needs 7 rounds in both cases.

NumberYield_rounding_downNumber_of_tries_rounding_downGuesses_rounding_downYield_rounding_upNumber_of_tries_rounding_upGuesses_rounding_up
106[50-25-12-6-3-1]-17[51-26-13-7-4-2-1]
2-17[50-25-12-6-3-1-2]06[51-26-13-7-4-2]
315[50-25-12-6-3]-17[51-26-13-7-4-2-3]
406[50-25-12-6-3-4]15[51-26-13-7-4]
5-17[50-25-12-6-3-4-5]-17[51-26-13-7-4-6-5]BANK WINS
624[50-25-12-6]06[51-26-13-7-4-6]
706[50-25-12-6-9-7]24[51-26-13-7]
8-17[50-25-12-6-9-7-8]-17[51-26-13-7-10-9-8]BANK WINS
915[50-25-12-6-9]06[51-26-13-7-10-9]
1006[50-25-12-6-9-10]15[51-26-13-7-10]
11-17[50-25-12-6-9-10-11]-17[51-26-13-7-10-12-11]BANK WINS
1233[50-25-12]06[51-26-13-7-10-12]
1306[50-25-12-18-15-13]33[51-26-13]
14-17[50-25-12-18-15-13-14]-17[51-26-13-20-17-15-14]BANK WINS
1515[50-25-12-18-15]06[51-26-13-20-17-15]
1606[50-25-12-18-15-16]-17[51-26-13-20-17-15-16]
17-17[50-25-12-18-15-16-17]15[51-26-13-20-17]
1824[50-25-12-18]-17[51-26-13-20-17-19-18]
1906[50-25-12-18-21-19]06[51-26-13-20-17-19]
20-17[50-25-12-18-21-19-20]24[51-26-13-20]
2115[50-25-12-18-21]-17[51-26-13-20-23-22-21]
22-17[50-25-12-18-21-23-22]06[51-26-13-20-23-22]
2306[50-25-12-18-21-23]15[51-26-13-20-23]
24-17[50-25-12-18-21-23-24]-17[51-26-13-20-23-25-24]BANK WINS
2542[50-25]06[51-26-13-20-23-25]
2606[50-25-37-31-28-26]42[51-26]
27-17[50-25-37-31-28-26-27]-17[51-26-39-33-30-28-27]BANK WINS
2815[50-25-37-31-28]06[51-26-39-33-30-28]
2906[50-25-37-31-28-29]-17[51-26-39-33-30-28-29]
30-17[50-25-37-31-28-29-30]15[51-26-39-33-30]
3124[50-25-37-31]-17[51-26-39-33-30-32-31]
3206[50-25-37-31-34-32]06[51-26-39-33-30-32]
33-17[50-25-37-31-34-32-33]24[51-26-39-33]
3415[50-25-37-31-34]-17[51-26-39-33-36-35-34]
3506[50-25-37-31-34-35]06[51-26-39-33-36-35]
36-17[50-25-37-31-34-35-36]15[51-26-39-33-36]
3733[50-25-37]-17[51-26-39-33-36-38-37]
3806[50-25-37-43-40-38]06[51-26-39-33-36-38]
39-17[50-25-37-43-40-38-39]33[51-26-39]
4015[50-25-37-43-40]-17[51-26-39-45-42-41-40]
4106[50-25-37-43-40-41]06[51-26-39-45-42-41]
42-17[50-25-37-43-40-41-42]15[51-26-39-45-42]
4324[50-25-37-43]-17[51-26-39-45-42-44-43]
4406[50-25-37-43-46-44]06[51-26-39-45-42-44]
45-17[50-25-37-43-46-44-45]24[51-26-39-45]
4615[50-25-37-43-46]-17[51-26-39-45-48-47-46]
47-17[50-25-37-43-46-48-47]06[51-26-39-45-48-47]
4806[50-25-37-43-46-48]15[51-26-39-45-48]
49-17[50-25-37-43-46-48-49]-17[51-26-39-45-48-50-49]BANK WINS
5051[50]06[51-26-39-45-48-50]
5106[50-75-62-56-53-51]51[51]
52-17[50-75-62-56-53-51-52]-17[51-76-64-58-55-53-52]BANK WINS
5315[50-75-62-56-53]06[51-76-64-58-55-53]
5406[50-75-62-56-53-54]-17[51-76-64-58-55-53-54]
55-17[50-75-62-56-53-54-55]15[51-76-64-58-55]
5624[50-75-62-56]-17[51-76-64-58-55-57-56]
5706[50-75-62-56-59-57]06[51-76-64-58-55-57]
58-17[50-75-62-56-59-57-58]24[51-76-64-58]
5915[50-75-62-56-59]-17[51-76-64-58-61-60-59]
6006[50-75-62-56-59-60]06[51-76-64-58-61-60]
61-17[50-75-62-56-59-60-61]15[51-76-64-58-61]
6233[50-75-62]-17[51-76-64-58-61-63-62]
6306[50-75-62-68-65-63]06[51-76-64-58-61-63]
64-17[50-75-62-68-65-63-64]33[51-76-64]
6515[50-75-62-68-65]-17[51-76-64-70-67-66-65]
6606[50-75-62-68-65-66]06[51-76-64-70-67-66]
67-17[50-75-62-68-65-66-67]15[51-76-64-70-67]
6824[50-75-62-68]-17[51-76-64-70-67-69-68]
6906[50-75-62-68-71-69]06[51-76-64-70-67-69]
70-17[50-75-62-68-71-69-70]24[51-76-64-70]
7115[50-75-62-68-71]-17[51-76-64-70-73-72-71]
72-17[50-75-62-68-71-73-72]06[51-76-64-70-73-72]
7306[50-75-62-68-71-73]15[51-76-64-70-73]
74-17[50-75-62-68-71-73-74]-17[51-76-64-70-73-75-74]BANK WINS
7542[50-75]06[51-76-64-70-73-75]
7606[50-75-88-81-78-76]42[51-76]
77-17[50-75-88-81-78-76-77]-17[51-76-89-83-80-78-77]BANK WINS
7815[50-75-88-81-78]06[51-76-89-83-80-78]
7906[50-75-88-81-78-79]-17[51-76-89-83-80-78-79]
80-17[50-75-88-81-78-79-80]15[51-76-89-83-80]
8124[50-75-88-81]-17[51-76-89-83-80-82-81]
8206[50-75-88-81-84-82]06[51-76-89-83-80-82]
83-17[50-75-88-81-84-82-83]24[51-76-89-83]
8415[50-75-88-81-84]-17[51-76-89-83-86-85-84]
85-17[50-75-88-81-84-86-85]06[51-76-89-83-86-85]
8606[50-75-88-81-84-86]15[51-76-89-83-86]
87-17[50-75-88-81-84-86-87]-17[51-76-89-83-86-88-87]BANK WINS
8833[50-75-88]06[51-76-89-83-86-88]
8906[50-75-88-94-91-89]33[51-76-89]
90-17[50-75-88-94-91-89-90]-17[51-76-89-95-92-91-90]BANK WINS
9115[50-75-88-94-91]06[51-76-89-95-92-91]
9206[50-75-88-94-91-92]15[51-76-89-95-92]
93-17[50-75-88-94-91-92-93]-17[51-76-89-95-92-94-93]BANK WINS
9424[50-75-88-94]06[51-76-89-95-92-94]
9506[50-75-88-94-97-95]24[51-76-89-95]
96-17[50-75-88-94-97-95-96]-17[51-76-89-95-98-97-96]BANK WINS
9715[50-75-88-94-97]06[51-76-89-95-98-97]
98-17[50-75-88-94-97-99-98]15[51-76-89-95-98]
9906[50-75-88-94-97-99]-17[51-76-89-95-98-100-99]
100-17[50-75-88-94-97-99-100]06[51-76-89-95-98-100]

The frequencies are as follows

Number of triesYield for playerFrequency
7-137
6032
5116
428
334
242
151

If you play the game from 1 to 100 (included), you win 20 euros.

If we add a bit of randomness, we see that the profit for the play goes down to 5 euro, but in no scenario the bank will win (if the bank plays with random numbers)

Conclusion

The money scheme is not profitably enough for the bank to win money if the bank uses random numbers. Of course the bank can play only with the numbers that need 7 guesses. Be aware that the numbers are mostly different if the player rounds up instead of rounds down, but there are some winning numbers for the bank : 5, 8,11,27,49,52,74,77,87,90,93, and 96.

Leave a Reply

Your email address will not be published. Required fields are marked *