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:
- 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.
- 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:
- If I said your guess of 50 was too high, guess the middle of 1 to 49. That’s 25.
- If I said 25 was too low, guess the middle of 26 to 49. That’s 37.
- 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:
- We start with 100 possible numbers
- After first guess: 50 numbers left
- After second guess: 25 numbers left
- After third guess: 12-13 numbers left
- After fourth guess: 6-7 numbers left
- After fifth guess: 3-4 numbers left
- After sixth guess: 1-2 numbers left
- 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.
Number | Yield_rounding_down | Number_of_tries_rounding_down | Guesses_rounding_down | Yield_rounding_up | Number_of_tries_rounding_up | Guesses_rounding_up | |
1 | 0 | 6 | [50-25-12-6-3-1] | -1 | 7 | [51-26-13-7-4-2-1] | |
2 | -1 | 7 | [50-25-12-6-3-1-2] | 0 | 6 | [51-26-13-7-4-2] | |
3 | 1 | 5 | [50-25-12-6-3] | -1 | 7 | [51-26-13-7-4-2-3] | |
4 | 0 | 6 | [50-25-12-6-3-4] | 1 | 5 | [51-26-13-7-4] | |
5 | -1 | 7 | [50-25-12-6-3-4-5] | -1 | 7 | [51-26-13-7-4-6-5] | BANK WINS |
6 | 2 | 4 | [50-25-12-6] | 0 | 6 | [51-26-13-7-4-6] | |
7 | 0 | 6 | [50-25-12-6-9-7] | 2 | 4 | [51-26-13-7] | |
8 | -1 | 7 | [50-25-12-6-9-7-8] | -1 | 7 | [51-26-13-7-10-9-8] | BANK WINS |
9 | 1 | 5 | [50-25-12-6-9] | 0 | 6 | [51-26-13-7-10-9] | |
10 | 0 | 6 | [50-25-12-6-9-10] | 1 | 5 | [51-26-13-7-10] | |
11 | -1 | 7 | [50-25-12-6-9-10-11] | -1 | 7 | [51-26-13-7-10-12-11] | BANK WINS |
12 | 3 | 3 | [50-25-12] | 0 | 6 | [51-26-13-7-10-12] | |
13 | 0 | 6 | [50-25-12-18-15-13] | 3 | 3 | [51-26-13] | |
14 | -1 | 7 | [50-25-12-18-15-13-14] | -1 | 7 | [51-26-13-20-17-15-14] | BANK WINS |
15 | 1 | 5 | [50-25-12-18-15] | 0 | 6 | [51-26-13-20-17-15] | |
16 | 0 | 6 | [50-25-12-18-15-16] | -1 | 7 | [51-26-13-20-17-15-16] | |
17 | -1 | 7 | [50-25-12-18-15-16-17] | 1 | 5 | [51-26-13-20-17] | |
18 | 2 | 4 | [50-25-12-18] | -1 | 7 | [51-26-13-20-17-19-18] | |
19 | 0 | 6 | [50-25-12-18-21-19] | 0 | 6 | [51-26-13-20-17-19] | |
20 | -1 | 7 | [50-25-12-18-21-19-20] | 2 | 4 | [51-26-13-20] | |
21 | 1 | 5 | [50-25-12-18-21] | -1 | 7 | [51-26-13-20-23-22-21] | |
22 | -1 | 7 | [50-25-12-18-21-23-22] | 0 | 6 | [51-26-13-20-23-22] | |
23 | 0 | 6 | [50-25-12-18-21-23] | 1 | 5 | [51-26-13-20-23] | |
24 | -1 | 7 | [50-25-12-18-21-23-24] | -1 | 7 | [51-26-13-20-23-25-24] | BANK WINS |
25 | 4 | 2 | [50-25] | 0 | 6 | [51-26-13-20-23-25] | |
26 | 0 | 6 | [50-25-37-31-28-26] | 4 | 2 | [51-26] | |
27 | -1 | 7 | [50-25-37-31-28-26-27] | -1 | 7 | [51-26-39-33-30-28-27] | BANK WINS |
28 | 1 | 5 | [50-25-37-31-28] | 0 | 6 | [51-26-39-33-30-28] | |
29 | 0 | 6 | [50-25-37-31-28-29] | -1 | 7 | [51-26-39-33-30-28-29] | |
30 | -1 | 7 | [50-25-37-31-28-29-30] | 1 | 5 | [51-26-39-33-30] | |
31 | 2 | 4 | [50-25-37-31] | -1 | 7 | [51-26-39-33-30-32-31] | |
32 | 0 | 6 | [50-25-37-31-34-32] | 0 | 6 | [51-26-39-33-30-32] | |
33 | -1 | 7 | [50-25-37-31-34-32-33] | 2 | 4 | [51-26-39-33] | |
34 | 1 | 5 | [50-25-37-31-34] | -1 | 7 | [51-26-39-33-36-35-34] | |
35 | 0 | 6 | [50-25-37-31-34-35] | 0 | 6 | [51-26-39-33-36-35] | |
36 | -1 | 7 | [50-25-37-31-34-35-36] | 1 | 5 | [51-26-39-33-36] | |
37 | 3 | 3 | [50-25-37] | -1 | 7 | [51-26-39-33-36-38-37] | |
38 | 0 | 6 | [50-25-37-43-40-38] | 0 | 6 | [51-26-39-33-36-38] | |
39 | -1 | 7 | [50-25-37-43-40-38-39] | 3 | 3 | [51-26-39] | |
40 | 1 | 5 | [50-25-37-43-40] | -1 | 7 | [51-26-39-45-42-41-40] | |
41 | 0 | 6 | [50-25-37-43-40-41] | 0 | 6 | [51-26-39-45-42-41] | |
42 | -1 | 7 | [50-25-37-43-40-41-42] | 1 | 5 | [51-26-39-45-42] | |
43 | 2 | 4 | [50-25-37-43] | -1 | 7 | [51-26-39-45-42-44-43] | |
44 | 0 | 6 | [50-25-37-43-46-44] | 0 | 6 | [51-26-39-45-42-44] | |
45 | -1 | 7 | [50-25-37-43-46-44-45] | 2 | 4 | [51-26-39-45] | |
46 | 1 | 5 | [50-25-37-43-46] | -1 | 7 | [51-26-39-45-48-47-46] | |
47 | -1 | 7 | [50-25-37-43-46-48-47] | 0 | 6 | [51-26-39-45-48-47] | |
48 | 0 | 6 | [50-25-37-43-46-48] | 1 | 5 | [51-26-39-45-48] | |
49 | -1 | 7 | [50-25-37-43-46-48-49] | -1 | 7 | [51-26-39-45-48-50-49] | BANK WINS |
50 | 5 | 1 | [50] | 0 | 6 | [51-26-39-45-48-50] | |
51 | 0 | 6 | [50-75-62-56-53-51] | 5 | 1 | [51] | |
52 | -1 | 7 | [50-75-62-56-53-51-52] | -1 | 7 | [51-76-64-58-55-53-52] | BANK WINS |
53 | 1 | 5 | [50-75-62-56-53] | 0 | 6 | [51-76-64-58-55-53] | |
54 | 0 | 6 | [50-75-62-56-53-54] | -1 | 7 | [51-76-64-58-55-53-54] | |
55 | -1 | 7 | [50-75-62-56-53-54-55] | 1 | 5 | [51-76-64-58-55] | |
56 | 2 | 4 | [50-75-62-56] | -1 | 7 | [51-76-64-58-55-57-56] | |
57 | 0 | 6 | [50-75-62-56-59-57] | 0 | 6 | [51-76-64-58-55-57] | |
58 | -1 | 7 | [50-75-62-56-59-57-58] | 2 | 4 | [51-76-64-58] | |
59 | 1 | 5 | [50-75-62-56-59] | -1 | 7 | [51-76-64-58-61-60-59] | |
60 | 0 | 6 | [50-75-62-56-59-60] | 0 | 6 | [51-76-64-58-61-60] | |
61 | -1 | 7 | [50-75-62-56-59-60-61] | 1 | 5 | [51-76-64-58-61] | |
62 | 3 | 3 | [50-75-62] | -1 | 7 | [51-76-64-58-61-63-62] | |
63 | 0 | 6 | [50-75-62-68-65-63] | 0 | 6 | [51-76-64-58-61-63] | |
64 | -1 | 7 | [50-75-62-68-65-63-64] | 3 | 3 | [51-76-64] | |
65 | 1 | 5 | [50-75-62-68-65] | -1 | 7 | [51-76-64-70-67-66-65] | |
66 | 0 | 6 | [50-75-62-68-65-66] | 0 | 6 | [51-76-64-70-67-66] | |
67 | -1 | 7 | [50-75-62-68-65-66-67] | 1 | 5 | [51-76-64-70-67] | |
68 | 2 | 4 | [50-75-62-68] | -1 | 7 | [51-76-64-70-67-69-68] | |
69 | 0 | 6 | [50-75-62-68-71-69] | 0 | 6 | [51-76-64-70-67-69] | |
70 | -1 | 7 | [50-75-62-68-71-69-70] | 2 | 4 | [51-76-64-70] | |
71 | 1 | 5 | [50-75-62-68-71] | -1 | 7 | [51-76-64-70-73-72-71] | |
72 | -1 | 7 | [50-75-62-68-71-73-72] | 0 | 6 | [51-76-64-70-73-72] | |
73 | 0 | 6 | [50-75-62-68-71-73] | 1 | 5 | [51-76-64-70-73] | |
74 | -1 | 7 | [50-75-62-68-71-73-74] | -1 | 7 | [51-76-64-70-73-75-74] | BANK WINS |
75 | 4 | 2 | [50-75] | 0 | 6 | [51-76-64-70-73-75] | |
76 | 0 | 6 | [50-75-88-81-78-76] | 4 | 2 | [51-76] | |
77 | -1 | 7 | [50-75-88-81-78-76-77] | -1 | 7 | [51-76-89-83-80-78-77] | BANK WINS |
78 | 1 | 5 | [50-75-88-81-78] | 0 | 6 | [51-76-89-83-80-78] | |
79 | 0 | 6 | [50-75-88-81-78-79] | -1 | 7 | [51-76-89-83-80-78-79] | |
80 | -1 | 7 | [50-75-88-81-78-79-80] | 1 | 5 | [51-76-89-83-80] | |
81 | 2 | 4 | [50-75-88-81] | -1 | 7 | [51-76-89-83-80-82-81] | |
82 | 0 | 6 | [50-75-88-81-84-82] | 0 | 6 | [51-76-89-83-80-82] | |
83 | -1 | 7 | [50-75-88-81-84-82-83] | 2 | 4 | [51-76-89-83] | |
84 | 1 | 5 | [50-75-88-81-84] | -1 | 7 | [51-76-89-83-86-85-84] | |
85 | -1 | 7 | [50-75-88-81-84-86-85] | 0 | 6 | [51-76-89-83-86-85] | |
86 | 0 | 6 | [50-75-88-81-84-86] | 1 | 5 | [51-76-89-83-86] | |
87 | -1 | 7 | [50-75-88-81-84-86-87] | -1 | 7 | [51-76-89-83-86-88-87] | BANK WINS |
88 | 3 | 3 | [50-75-88] | 0 | 6 | [51-76-89-83-86-88] | |
89 | 0 | 6 | [50-75-88-94-91-89] | 3 | 3 | [51-76-89] | |
90 | -1 | 7 | [50-75-88-94-91-89-90] | -1 | 7 | [51-76-89-95-92-91-90] | BANK WINS |
91 | 1 | 5 | [50-75-88-94-91] | 0 | 6 | [51-76-89-95-92-91] | |
92 | 0 | 6 | [50-75-88-94-91-92] | 1 | 5 | [51-76-89-95-92] | |
93 | -1 | 7 | [50-75-88-94-91-92-93] | -1 | 7 | [51-76-89-95-92-94-93] | BANK WINS |
94 | 2 | 4 | [50-75-88-94] | 0 | 6 | [51-76-89-95-92-94] | |
95 | 0 | 6 | [50-75-88-94-97-95] | 2 | 4 | [51-76-89-95] | |
96 | -1 | 7 | [50-75-88-94-97-95-96] | -1 | 7 | [51-76-89-95-98-97-96] | BANK WINS |
97 | 1 | 5 | [50-75-88-94-97] | 0 | 6 | [51-76-89-95-98-97] | |
98 | -1 | 7 | [50-75-88-94-97-99-98] | 1 | 5 | [51-76-89-95-98] | |
99 | 0 | 6 | [50-75-88-94-97-99] | -1 | 7 | [51-76-89-95-98-100-99] | |
100 | -1 | 7 | [50-75-88-94-97-99-100] | 0 | 6 | [51-76-89-95-98-100] |
The frequencies are as follows
Number of tries | Yield for player | Frequency |
7 | -1 | 37 |
6 | 0 | 32 |
5 | 1 | 16 |
4 | 2 | 8 |
3 | 3 | 4 |
2 | 4 | 2 |
1 | 5 | 1 |
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.