Reply
Thu 28 May, 2009 06:15 am
Code:
Let n be a positive integer, and x an unknown non-negative integer less than n. Suppose you may make guesses for the value of x, and after each guess you are told whether it is correct, too low, or too high. How large may n be so that you can still guarantee to make a correct guess within 20 guesses?
Post your postulate again, and leave out the silly "code" command. As it stands now, no one can read the entire postulate.
Just as an initial guess, i'd say 2^20 or 2^21. Maybe 1+2^20 or 1+2^21....
@McGentrix,
Cool . . . how did you accomplish that? I tried reply, but got the same post.
I assume that you want to optimize your guesses. It would be silly to guess "1", "2", "3", etc.
When you're down to one guess, there has to be only one answer possible.
For two guesses, there should be three possible answers (a midpoint, and one possible value on either side). Therefore, If you have two guesses, then the largest that n can be is 4.
For three guesses, there must be a midpoint and three values on either side, so n has a maximum value of 8.
For four guesses, a midpoint and a range of seven numbers on either side, so n can be 16.
So it looks like the maximum value of n is two raised to the power of the number of guesses, so 2^20.
The correct answer is (2^20)-1 .
Another cool one.
Let n be a positive integer, and x an unknown non-negative integer less than n. Suppose you may ask questions of the form "Is x less than t?", where t is an arbitrary integer, but the answer to each question will be told only after you ask another question (i. e., the answers are delayed by one question; note that the last question will not be answered at all). How large may n be so that you can still guarantee to determine x with only 30 questions?
@Setanta,
I just deleted the [ code ] [ /code ] from his post.
@McGentrix,
That's fine, as far as it goes . . . but i've never seen a way to quote a post, other than to hit "reply" and the copy and paste the text into ubb code for a quote. Perhaps you could enlighten me further.
@Setanta,
Do you not have the "quote" button right next to the "reply" button?
@rohtarantula,
rohtarantula wrote:The correct answer is (2^20)-1 .
And how did you determine that?