Follow

Some people asked me to share a lvery difficult yet simple logic puzzle that has stumped my friends. It is also my favorite interview question.

First off some background. The problem is not a trick question, as much as it may seem like one. There is no play on words, no hidden exception. Everything in this problem is exactly how it is presented and the answer doesn't rely on any slight of hand. Take this puzzle at face value.

Also **ALL ANSWERS NEED CONTENT WARNINGS** I do not want you spoiling it for others. This goes for questions and hints too.

Now on to the puzzle:

There is a room with 100 jars with lids on them all in a row. There is also a stack of papers, 100 papers each labeled 1 to 100. The papers are shuffled and one paper placed into each pot randomly.

You and your assistant are in an a joining room. Your assistant is allowed to enter the room, look in all 100 pots, and if they wish they can pick any 2 pots and switch the paper in them. They can only do this one time, they do not have to do this they can choose to also do nothing. At this point they leave the room, without talking to you.

Next, someone tells you a random number from 1 to 100. Your goal is to enter the room and open a pot tht has that number in it. You are allowed to open, at most, 50 of the pots.

Whatever process you use to open those pots must **guarantee** that by the time you open the 50th pot that the number you were given will be found. Obviously your assistant didn't know what the number is at any point.

What rules do you give your assistant, and what rules do you follow, to ensure you are successful?

@MutoShack @inditoot

Β· Β· 10 Β· 10 Β· 8

@freemo @MutoShack

This sounds more like a probability question then a riddle πŸ™‚ Will give it shot though

@inditoot
There is no math or probabilities needed. Any solution works 100% of the time.

@MutoShack

@freemo @MutoShack

lol, I wasted a single page doing math on it πŸ˜…. its getting interesting though

possible solution 

@freemo Isn't this just merge sort?

possible solution 

@matrix A merge sort would require more than a single swap, so no.

@freemo @MutoShack @inditoot leave the lid off the pot with the number I need.

Thx assistant. πŸ™‚

@Wetrix

He doesnt know what number you need when he goes in. Also id say this is a trick. The answer is nothing tricky like that.

@MutoShack @inditoot

@freemo @MutoShack @inditoot I'd just get a shady assistant that would get the guys that set up the test to text him πŸ˜‚

@Wetrix @freemo @MutoShack

πŸ˜‚πŸ˜‚πŸ˜‚ That is another way to solve it
although there are multiple ways we can increase our chances but they are not enough to guarantee that we gonna get that number in 50 tries.

solution, excessive smugness 

@freemo

The jars with papers inside represent a permutation, every piece of paper points to the next jar in the permutation, say we number the jars from left to right. As all permutation, this one can be represented as a collection of cycles. Two key insights about these cycles:
1. Every cycle containing the jar numbered $k$ neccessarily contains the piece of paper with $k$ written on it, otherwise it wouldn't be a cycle.
2. At most one cycle has length greater than $50$.
With these insights the solution is simple. Your assistant looks at the whole permutation, and if any of the cycles has length greater than $50$ they switch the pieces of paper to break the cycle in half. They do nothing if there are no big cycles. Now you get told the number you are looking for and go for the jar numbered with it. Afterwards just trust the pieces of paper to lead you to the correct jar.

Thanks for this puzzle, solving it gave me a very needed confidence boost. *smugness incoming* Especially since I didn't even need to use paper.

solution, excessive smugness 

@timorl Correct, I'm very impressed :)

Rule number one to solving any problem: use graphs (as in Graph Theory)

Comments on this weird puzzle. 

@freemo

No tricks, which means my friend cannot move the pots around, the pots aren't clear, and by "each paper is labelled 1 to 100" it doesn't mean every piece of paper has every number on it.

By nature, I'm *not* a logical person, but I'll give this puzzle my best shot. Thanks for giving me something to do with my time! πŸ‘

Comments on this weird puzzle. 

@MutoShack Those assumptions are correct :)

proposed change 

@freemo great puzzle, but I would propose that you have physically numbered the jar/pots as well. If the room contains a jumble of un-ordered pots/jars you would have to have an agreed upon organization of the jars with your assistant. If neither of you sees the room ahead of time 100 jars can look pretty random.

Also, just a nit-picky thing. Call them jars or pots or something else, but it was confusing that you switched between the wording. I would just call them "clay pots" to avoid the see-through glass jar question, personally. :)

proposed change 

@Absinthe Yes, true, you and your assistant do need an agreed upon ordering scheme. In the future I will number the pots.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.