# n hats/boxes problem [closed]

Do anyone have a clue about the below problem:

A set of n persons with a distinct hats tagged accordingly by $$1,...,n$$ leave their hats in a room and leave the room. A naughty boy then take the hats and permutes them adversarially into n closed boxes numbered from $$1$$ to $$n$$, each hat in a distinct box, and closes the boxes. A standbyer that is in the room sees all this and records all hats placing. With a good will, but limited ability, all he is allowed to do is to open only two boxes and exchange the hats between them. This is done just once. Then the standbyer goes away and does not communicate with any person. Suppose the $$n$$ persons and the standbyer prepare for such situation, what should the standbyer do so that every person that might come in the room will find his hat after opening at most $$n=2$$ boxes (worst case, deterministic).

## closed as off-topic by Travis, Vinyl_cape_jawa, Eevee Trainer, max_zorn, mrtaurhoMar 5 at 6:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Travis, Vinyl_cape_jawa, Eevee Trainer, max_zorn, mrtaurho
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to Math.SE! Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers. – Brian Mar 4 at 21:24
• The word is "bystander" not "standbyer." – saulspatz Mar 4 at 21:24
• Are you sure it's not a worst case of n/2? – Acccumulation Mar 4 at 21:26
• Do the hats have numbers on them? – saulspatz Mar 4 at 21:27
• This is a rewording of the well known 100 prisoners problem. Thinking about the optimal strategy for that problem will show you what the bystander should do. – lulu Mar 4 at 21:36