Advertisement

We need your help now

Support from readers like you keeps The Journal open.

You are visiting us because we have something you value. Independent, unbiased news that tells the truth. Advertising revenue goes some way to support our mission, but this year it has not been enough.

If you've seen value in our reporting, please contribute what you can, so we can continue to produce accurate and meaningful journalism. For everyone who needs it.

Abacus not required. abacus via Shutterstock

How to guess any number under 1,000 in ten steps or less

Here’s a fun party trick to hone in the weeks to come.

HERE IS A fun math party trick.

Tell someone to pick a number between 1 and 1,000. Your goal is to guess the number.

For each guess you make, your friend tells you one of three things: you guessed the number, your guess was high, or your guess was low.

Amazingly, if you guess properly, it is possible to get to any number your friend chooses in 10 or fewer guesses.

The trick to this is to constantly be cutting the amount of numbers you have to consider in half. This process demonstrates binary search, a foundational concept in technology. But more on that later.

How to guess the number in 10 steps or under

Suppose your friend chooses the number 334.

Your First Guess: In this game, your first guess should always be 500, halfway between 1 and 1000. So, you guess 500, and your friend tells you that their number is lower. Now you know that the number is somewhere between 1 and 500, and you have knocked out everything between 500 and 1000. You have, in one guess, already gotten rid of half the possibilities.

Your Second Guess:You know that the number is between 1 and 500, so you again take the halfway point between these two, and you guess 250. Now your friend tells you your guess is too low, so you know the number is somewhere between 250 and 500. In just two steps, you have knocked out 750 numbers, and are just looking at about 250 numbers, a quarter of our original set.

Keep Doing This: Your next guess is halfway between 250 and 500, or 375. Your friend tells you this is too high, so now you know that the number is between 250 and 375. You have reduced your range to about 125 possibilities.

The fourth guess is the midpoint of 250 and 375: Unfortunately, this is a decimal number – 312.5, but we can simply round up to 313. This guess is too low, but we have again eliminated half the remaining numbers, leaving us with the 61 numbers between 313 and 375.

Your fifth guess is halfway between 313 and 375: 344. Again, this is too high, but you’re down to the 30 numbers between 313 and 344.

Your sixth guess is halfway between 313 and 344: 328.5, rounded up to 329. Too low. You know the number is between 329 and 344, leaving just 14 possibilities.

Your seventh guess is halfway between 329 and 344: 336.5, rounded up to 337. Too high, but you’re getting close — only the seven numbers between 329 and 227 are left.

Your eighth guess is halfway between 329 and 337: 333. Juuust too low. But now there are just three remaining possibilities — you know the number is between 333 and 337, so it must be one of 334, 335, or 336.

Your ninth guess is the middle option of 335, and you are told that your guess is too high.

And now you know that the number is between 333 and 335. There is only one such number, and so your tenth, and final guess, is 334, your friend’s number.

This process will work for any number between 1 and 1000, and you will always find the number within 10 guesses.

Binary search

This game is a simple example of a binary search process.

This works well for any ordered list, like a directory of employees at a corporation, ordered by name. Suppose we are trying to find a particular name on the list.

We start by comparing the desired name to the middle name in the list. If they match, then yay! We are done.

If the middle name comes after the desired name, we throw out the second half of the list, and just look at the first half.

If the middle name comes before the desired name, we do the opposite — dump the names before the middle name, and just search the second half of the original list. Then we just keep repeating this process, throwing out half the remaining names each time, until we find our name.

This is such a simple, recursive process that it is ideally suited to being run on computers, and this is indeed how most database systems search through sorted lists of data.

One of the coolest things about binary search is that the number of steps you need to find your target increases logarithmically with the size of the set you are looking in. What this means is that if you double the size of your set, you only wind up adding one extra step. If I wanted to find a number between 1 and 2000, my first guess is going to be 1000 (halfway between 1 and 2000), and then I’ll be looking at either the numbers between 1 and 1000 or between 1001 and 2000, and we are back where we started — trying to find one number among a thousand numbers.

Extending this out, if we wanted to find a number between 1 and 1,000,000, we actually only need 20 steps to get to the number. For those of you familiar with logarithms, this is because the base 2 logarithm of 1,000,000 is just under 20.

Processes like this that add steps at a logarithmic rate with respect to the size of the input are pretty rare — usually, if I double the size of my input, I at least double the number of steps I need to take to solve my problem, and often need to add many, many more steps than that.

Binary search is a great example of using a very simple concept — repeatedly cutting my search region in half by always guessing the middle number — and getting a very powerful tool from that concept. This is one of the central, big ideas in math: Start with a simple notion, and discover all the interesting, often surprising, implications of that notion.

- Andy Kiersz

Maths Week puzzles>
Kids who do well on this test may have unrealised potential>

Readers like you are keeping these stories free for everyone...
A mix of advertising and supporting contributions helps keep paywalls away from valuable information like this article. Over 5,000 readers like you have already stepped up and support us with a monthly payment or a once-off donation.

Published with permission from
View 28 comments
Close
28 Comments
    Install the app to use these features.
    Mute Right Wing Steve ©
    Favourite Right Wing Steve ©
    Report
    Aug 18th 2013, 7:49 AM

    €3m is nothing, you couldn’t even pay off the Sligo county manager with that.

    50
    Install the app to use these features.
    Mute Doey Walsh
    Favourite Doey Walsh
    Report
    Aug 18th 2013, 7:54 AM

    I wouldn’t say no to it ;)

    7
    Install the app to use these features.
    Mute WanderArch
    Favourite WanderArch
    Report
    Aug 18th 2013, 8:00 AM

    So let me get this straight, banks are lending to agriculture and property development, one sector that is inherently inefficient and can get pretty much all of the grants by stamping their foot m, the other landed us in a mahoosive mess, with loans still outstanding to the tune of billions.
    Banks aren’t lending to R+D – the one area we know we can do quite well in, because we’re already doing quite well in it.
    People still wonder how a) we got into this mess, and b) we are still in it. This country is amazing.
    A. Maze. Ing.

    49
    Install the app to use these features.
    Mute Fergal Gaultier
    Favourite Fergal Gaultier
    Report
    Aug 18th 2013, 10:10 AM

    I agree that is a bad figure but the reality is Ireland has never been great at R & D. I don’t know where R&D money comes from elsewhere but it is a very risky low return business and I doubt bank loans are the way to go.

    7
    Install the app to use these features.
    Mute censored
    Favourite censored
    Report
    Aug 18th 2013, 8:15 PM

    Which came first, the chicken or the egg? Check out the story of stripe, and ask yourself why they had to move to the US.

    1
    Install the app to use these features.
    Mute FutureTech
    Favourite FutureTech
    Report
    Aug 18th 2013, 9:38 AM

    I am co-founder of a hi-tech SME. We’ve raised almost €1m from VCs and have contracts of approx €1m with some of the world’s biggest companies ( all exports). The lowest qualification in the company is an M.Sc. We were refused company credit cards until our CEO gave personal guarantees and we now have limits on the cc’s of €140. That’s the banks in Ireland. But glad 2 hear the property developers can get cash. That’s a lovely stable industry.

    28
    Install the app to use these features.
    Mute Thomas M Bourke
    Favourite Thomas M Bourke
    Report
    Aug 18th 2013, 9:59 AM

    And people wonder why my company does ALL its banking and lending outside the republic!

    11
    Install the app to use these features.
    Mute Fintan O HEifernain
    Favourite Fintan O HEifernain
    Report
    Aug 18th 2013, 9:10 AM

    Insanity is repeating the same thing over and over and expecting different results. It’s evident that the banks are hoping for a return to the anomaly that was the property bubble.Try again, it’s not going to happen

    14
    Install the app to use these features.
    Mute Anthony Byrne
    Favourite Anthony Byrne
    Report
    Aug 18th 2013, 9:29 AM

    3 Mil? How much did “Fingers” walk with ? Remind me again ?

    11
    Install the app to use these features.
    Mute Patrick
    Favourite Patrick
    Report
    Aug 18th 2013, 10:30 AM

    The minister for small firms has small pockets.

    9
    Install the app to use these features.
    Mute censored
    Favourite censored
    Report
    Aug 18th 2013, 8:14 PM

    Of course, those are the traditional “safe as houses” sectors of the Irish economy. Just think about the qualifications for being a banker in Ireland – have you ever seen such a shower of smug gits?

    3
    Install the app to use these features.
    Mute Austin Smith
    Favourite Austin Smith
    Report
    Aug 20th 2013, 12:15 PM

    This blog makes me realize the energy of words and pictures. As always your things are just gorgeous and I am grateful that you let us look in! Keep coming up with ideas.
    Small Business Loan

    1
    Install the app to use these features.
    Mute Robert Squires
    Favourite Robert Squires
    Report
    Aug 19th 2013, 9:43 AM

    We are a sme with a patent product that we are Bringing to the Irish market .We have been refused credit from the banks as they need personal guarantees so we told them that we have no problem signing personal but we have no assets they still would not give us credit .We went to dublin city enterprises board and got approved for the 10 thousand euro feasibility grant we spent 24 thousand euro and now they have told us we are only getting 5650 euro as we did not employ an out side company to do our market research what a joke spend 24.000 and get 5650 . There is no help for sme in this country it’s a big joke !!!!

    1
Submit a report
Please help us understand how this comment violates our community guidelines.
Thank you for the feedback
Your feedback has been sent to our team for review.
JournalTv
News in 60 seconds