I have been following Bjarne Stroustrup’s Programming - Principles and Practices using C++ for quite a while now, and I stumbled upon this question recently. You are supposed to make a program which guesses the number the user is thinking of (between 1 and 100) by asking no more than seven questions.
This question reminded me of something that I had read somewhere a while back about: the binary search algorithm.
Although I do not know much (~nothing) about this algorithm, I was familiar with the basic concept. What this algorithm does, basically, is that instead of looking through the entire data for the required value, it eliminates half of it with each step.
Think of it like this: What do you do when you want to open to a particular page in a book? You randomly open the book to a page, then see whether the page you need to go to is before that page or after it. Then, you end up on another page. You again repeat what you did. If the required page is before the opened page, you go back; if it is after, you flip the pages forward.
Anyways, I made the program. I was ecstatic.
Aren’t we humans funny? Getting filled with emotions over the littlest things in life. But maybe that is why we were created. Too bad, we can’t just apply the search algorithm to find the true purpose of why we’re here.