# The Hat Problem: why use PIE?

Suppose that each of $$n$$ men at a party throws his hat into the center of the room. The hats are first mixed up, and then each man randomly selects a hat. What is the probability that

(a) None of the men selects his own hat;

In this question, I know that the answer given uses Principle of Inclusion-Exclusion (PIE), but I have the following solution. Could someone please explain why this does not work and how I am supposed to figure out for other such questions when to use my way, and when to use PIE?

|Probability Space| = n! ways of arranging |Event that every person gets any hat that is not theirs| = Step 1: Person 1 picks any hat other than theirs in n-1 ways Step 2: Person 2 picks any hat other than theirs and the hat already picked in (n-1)-1=n-2 ways...and so on. Total cardinality for the event = (n-1)!

Therefore P = (n-1)!/n!

• But what if person 1 picked person 2's hat? Then it is (n-1) ways for person 2, not (n-2). It is one of the many such nuances you will get into. That is why derangement solution through PIE. Commented Oct 12, 2020 at 6:46
• Thanks! That makes sense. Could I have general tips about how to think of such nuances? Commented Oct 12, 2020 at 6:48

What if the first person picked the second person's hat and then the second person has got $$n-1$$ instead of $$n-2$$ ways to pick a hat that is not his own.