Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Guess Who - Binary Search

If you're playing "Guess Who?" this Christmas and want an edge against your opponent, it's statistically more likely that you will win if you implement a binary search to narrow down your suspect. This way you eliminate the most amount of people with the least number of questions. You will have a one-third chance to guess correctly after just 3 questions and are guaranteed to know who the person is within 5 questions, sometimes 4.

The only way that I can see how you can do this is by using "or" conjunctions in order to include more people in your questions. E.g. do they have black or white hair? Luckily this is legal as the only rule is that your opponent must be able to answer with yes or no. Coming up with the relevant questions to ensure you are including exactly half the remaining population at a time in your questions is hard, so I have come up with the decision tree below:

Happy holidays!

Last updated: 24th December 2020
First published: 24th December 2020

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch