The Mathematical Game

A and B are playing a game.

Player A asks B to choose a number from 1 to 100,000 and keep it as a secret.

Player A has to guess the secret number. Player A will get as many tries as he wants. But the rule is that whenever player A guesses a number (let that no. be x), Player B will tell him if x is greater than or less than the secret number.

How many tries does A need to surely guess the secret number?


The answer is 17.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Archit Boobna
Nov 30, 2014

In the whole solution i've assumed that A will not get the correct answer without guessing the required number of times. Let's assume that A's first guess is p 1 { p }_{ 1 } . Then the chances of p 1 { p }_{ 1 } being less than the answer is 100000 p 1 100000 \frac { 100000-{ p }_{ 1 }}{ 100000 } and the chances of p being greater than the answer is p 1 1 100000 \frac { { p }_{ 1 }-1 }{ 100000 } . Let these two fractions be x 1 { x }_{ 1 } and x 2 { x }_{ 2 } where x 1 < x 2 { x }_{ 1 }<{ x }_{ 2 } . We need two get minimum possible value of x 1 { x }_{ 1 } to reduce the number of turns required. By solving we will get, p 1 { p }_{ 1 } =50000. So the first guess should be 50000. Now, there will be 2 cases,

  1. Secret Number<50000
  2. Secret Number>50000

In case 1, A's second guess would be p 2 { p }_{ 2 } , on solving, gives us 25000. In case 2, A's second guess would be p 2 { p }_{ 2 } + p 1 { p }_{ 1 }

We will repeat this n times, till p n { p }_{ n } becomes 1 (actually less than 1). We are halving p on every step. By halving 100000 n times, we get a value less than 1. So we get the equation:-

100000 2 n < 1 100000 < 2 n B y p u t t i n g v a l u e s w e g e t min ( n ) = 17 \frac { 100000 }{ { 2 }^{ n } } <1\\ 100000<{ 2 }^{ n }\\ By\quad putting\quad values\quad we\quad get\\ \min { (n)=\boxed { 17 } }

The mechanism behind the solving of this problem is similar to a searching method used in programming called Binary Search.

The maximum number of guesses for a certain answer would be if you were to start from the middle ( 50000 50000 ) and divide by 2 (or multiply by 1.5) each step through according to the result.provided (Greater/Less than). The minimum would be when the secret number is 50000 50000 and the greatest would be when the secret number is 1 1 or 100000 100000 . The minimum would require only one guess.

For the maximum, the number of guesses required would be log 2 100000 \large{\lceil\log_{2}{100000}\rceil} 17 17

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...