Tuesday, November 22, 2011

Fastest way to guess a number between 1 and 100?

I need to find the fatest way to guess a number between one and one hundred (inclusive). By fastest I mean the fewest number of questions and they can only be yes or no questions.|||You want to ask question that reduces the number of possibilities by half each time. When you have only two or three possibilities left, take guesses.





So I have a number, and I chose it so that it will take the maximum number of ways with the algorithm.





First: "Is it greater than 50?" NO. So it's between 1 and 50.


Second: "Is it greater than 25?" YES. So it's between 26 and 50.


Third: "Is it greater than 38?" NO. So it's between 26 and 38.


Fourth: "Is it greater than 32?" NO. So it's between 26 and 32.


Fifth: "Is it greater than 29?" NO. So it's between 26 and 29.


Sixth: "Is it greater than 27?" YES. So it's either 28 or 29.


Seventh: "Is it 28?" NO. So it's 29.


Eighth: "Is it 29?" YES.





It will always take between six and eight questions.|||To be fastest you need to reduce the possibilities by half each time.





It's boring but is it between 1 and 50?





Then between either 1 and 25, or 51-75.





Then 1 and 13, or 26 to 37, or 51 to 63 or 75 to 87, depending on the previous answer.





Then half again and continue until you get the answer.|||9 moves tops ask someone to think of a number between 1-100 the only answer they can give is higher or lower so you say each time you halve your remaining guess so say the number is 36 guessed you start 50 (lower) 25 (higher) 37 (lower) 32 (higher) 35 (higher) you can only be left with 36


some guesses take a little bit longer but deffo no more than 9 moves|||Golden section optimization is the fastest method.





Proportion 38 and 62





Check if the number is greater than 38


Then divide the segment in the same proportion.|||is it more than 50...?


if yes...


is it more than 75?


if no...


then is it more than 62?


...





get the drift?


but am not sure if this is the fastest method|||Is the number even?


Just kicked 50 numbers out of the game :)

No comments:

Post a Comment