# What is the name of the problem where a bunch of people leave a party with the wrong hat?

In one of my math courses in university, we studied a problem where a number of people show up to a party, wearing hats. Each left with the wrong hat. I am pretty sure that there was some specific name for this problem.

What is the problem called? I would like to use this to calculate some Secret Santa matchings, so that nobody gets matched with themselves.

-
I've not heard a name for such problems, but the permutations involved (ones with no fixed point) are called derangements. –  Chris Eagle Nov 28 '11 at 22:12
Envelope matching problem ? BTW, the title made me laugh, +1 for that. –  Sasha Nov 28 '11 at 22:13

This sounds like the problème des rencontres or the derangement problem:

How many permutations $\pi\in\mathfrak{S}_n$ have no fixed points, that is, $\pi(i)\ne i$ for all $i\in [n]$?

I've also heard it called the hat-check problem.

The above quotation is from Richard Stanley, Enumerative combinatorics 1, p. 67. He analyzes the problem using the principle of inclusion and exclusion and attributes its first solution to Montmort.

-

D.J.S. Robinson calls one such problem the hat problem.

-