We start with all possible permutations of the 5 people wearing one of the 6 shirts and one of the 6 trousers (one permutation for shirts and one for trousers). That would be:
$$
P(6,5)\cdot{P(6,5)}=6!\cdot{6!}\qquad(1)
$$
Then we need to subtract all the cases where exactly one person wears same colour clothes. That would be:
$$
- P(6,1)\cdot{C(5,1)}\cdot{(6-1)!}\cdot{(6-1)!}\qquad(2)
$$
where:
- $C(5,1)$ are the persons wearing same colour clothes. If exactly one person, it could be person 1, or person 2, or... or person 5.
- $P(6,1)$ are the clothes that the above persons are wearing. We have 6 colours, so it could be any of the 6 colours.
- Now we are left with 4 people having to wear 5 different colours. The number of permutations (as per above) is: $P(5,4)\cdot{P(5,4)}=5!\cdot{5!}$
But we have now also subtracted cases where more than one person wears same colour. For two people wearing same colour, we subtracted these cases twice (once when considering the first person and again when considering the second person). We have the following:
- For exactly one person, we subtracted once
- For exactly two persons, we subtracted twice
- ...
- For exactly five persons, we subtracted five times
We now need to add back once the cases of exactly two persons wearing same clothes (because we subtracted twice). That would be:
$$
+ P(6,2)\cdot{C(5,2)}\cdot{(6-2)!}\cdot{(6-2)!}\qquad(3)
$$
where:
- $C(5,2)$ are the persons wearing same colour clothes. Eg, person 1 and 2, person 1 and 3 etc.
- $P(6,2)$ are the clothes that the above persons are wearing. We have 6 colours and two persons. This is a permutation because, for example: (person 1 = red and person 2 = blue) is different than (person 1 = blue and person 2 = red).
- Now we are left with 3 people having to wear 4 different colours. The number of permutations (as per above) is: $P(4,3)\cdot{P(4,3)}=4!\cdot{4!}$
Now consider the cases where exactly 3 people wear same colour clothes. With (2) we subtracted these three times. But with (3), we added them three times. We need to subtract them once. If you continue this logic you will see that we need to alternate subtraction and addition (for exactly one person, exactly two persons, exactly three persons etc.). The final formula is:
$$
\sum_{k=0}^5(-1)^k\cdot{P(6,k)}\cdot{C(5,k)}\cdot{(6-k)!}\cdot{(6-k)!}=222480
$$