Figure out the number I'm thinking of with a single question!

The numbers 1, 2, and 3, in a picture.
Cropped from a photograph by Charlie Wollborg on Unsplash.

Problem statement

I'm thinking of a number amongst 1, 2, and 3. You are allowed to ask me a single question, to which I will truthfully answer with “yes”, “no”, or “I don't know”.

How can you find out the number I picked?

Give it some thought!

If you need any clarification whatsoever, feel free to ask in the comment section below.

(I originally found this puzzle on Reddit.)

Solvers

Know how to solve this? Be the first to join the list of solvers by emailing me your solution!

Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:

  • Carlos C., Portugal;
  • Ventsislav K., Bulgaria;
  • Reza K., Iran;
  • Martin J., Czech Republic;
  • Macdara M., Ireland;
  • Luke J., UK;
  • Panicz G., Poland;
  • Santiago V., USA;
  • David H., Taiwan;
  • Pedro G., Portugal;
  • Boro S., North Macedonia;
  • Jerry J., USA;
  • Lucas K., Brazil;
  • Kees L., Netherlands;

Join the list of solvers by emailing me your solution!

Solution

Lots of people sent in their solutions and I was very pleased with the amount of different solutions people came up with! Hence, the solution I present here is not the only one, but it's one I find very elegant.

The question you will ask me is

“If I pick one of the other two numbers, is yours larger?”

If I picked 3, then I know 3 is larger than any of the two other numbers (1 and 2). Therefore, I answer “Yes.”.

If I picked 1, then I know 1 is smaller than any of the two other numbers (2 and 3). Therefore, I answer “No.”.

If I picked 2, then I have no idea if you got 1 or 3, and that implies I need to reply “I don't know.”.

That's a pretty elegant solution, isn't it?

Feel free to share alternative solutions in the comments!

Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.

Become a better Python 🐍 developer 🚀

+35 chapters. +400 pages. Hundreds of examples. Over 30,000 readers!

My book “Pydon'ts” teaches you how to write elegant, expressive, and Pythonic code, to help you become a better developer. Get it below!

Download from

Previous Post Next Post

Blog Comments powered by Disqus.