Adam, Bob and Charles, members of a certain team, insisted on sticking together, while taking their places on a bench, accommodating the whole team of n people, - while Dan and Eddy would not like to be placed one next to another.
In how many ways may all these requests be met, if n = 5, 8, 10.
Rem: Computer programs allowed only as verification of your analytically produced results.
Well, treat A, B and C a single person, for now.
Then the team can be ordered in (n-2)! ways, some of which seat D and E next to each other.
What is the proportion of these where D and E do not sit next to each other?
Well, D is at on end or the other with probability 2/(n-2), still treating ABC as a single "person". When D is at the end, E sits next to him with probability (1)/(n-3). D is not at the end with probability (n-4)/(n-2). When D is not at the end, E sits next to him with probability 2/(n-3).
So, the proportion of total arrangements where D sits next to E is (2/(n-2))*(1/(n-3)) + ((n-4)/(n-2))*(2/(n-3)) = (2n-6)/(n-2)/(n-3) = 2/(n-2). Therefore, the proportion where D does not sit next to E is (n-4)/(n-2). When n = 5, this is 1/3, which checks out.
So, still treating ABC as a single "person", the total number of arrangements where D and E do not sit next to each other is (n-2)!*(n-4)/(n-2) = (n-3)!*(n-4). When n = 5, this equals 2, which checks out.
Multiply this by 3! (ie, 6) to account for different orderings of A,B, and C, and the final formula is 6(n-3)!*(n-4).
When n = 5, this equals 6*2! = 12
When n = 8, this equals 24*5! = 2,880
When n = 10, this equals 36*7! = 181,440