In how many ways can five people line up to get on a bus, but two of the people refuse to stand next to each other?
Suppose the 5 people are A,B,C,D, and E. Suppose C and D are the two
that dont want to stand next to each other.
If there were no restrictions on how the stand, and anybody could stand next
to anybody else, the answer would be 5! or 120.
However we must subtract from that number, the number of ways
C could stand immediately IN FRONT OF D, and also subtract the
number of ways C could stand immediately BEHIND D.
We consider this as 3 single people A,B, and E plus 1 couple CD.
This is 4 things, or 4!.
We double that because there are also 4! ways in which we could have
the four things A,B, and E plus the couple DC.
So the answer is 5! - 2·4! = 120 - 2*24 = 120 - 48 = 72 ways.
Edwin