Combinatorics - how many ways for 10 people to make a line with restrictions I'm self-studying for a probability and statistics course and ran into a problem with this practice exercise:
Persons A and B make a random line with 8 other people. What is the probability that there are at most 2 people between A and B?
I tried to first calculate separately the probabilities for the cases of no-one between A and B, 1 person between A and B, and 2 people between A and B. However I must be doing something wrong with calculating the number of favorable cases because all I'm getting is astronomically low odds. Here's my attempt for the first two cases:
With no-one between A and B we can choose their places in $2*1+8*2 = 18$ ways, because if A is at either end of the line we only have 1 possible place for B. If A is not at an end of the line we have 8 possible places for A and 2 for B. Then the probability is $\frac{18}{10!} \approx 4.6*10^-6$. ($10!$ is the total amount of possible lines).
For the case with 1 person between A and B we can choose that person in 8 ways. We can choose the arrangement of A and B around this person in 2 ways. Then we can choose the position of this 3-person line in the 10-person line in 8 ways. So the probability is $\frac{8*2*8}{10!} \approx 3.5*10^-5$
Looking forward to your ideas and explanations.
 A: (0) If there is nobody between A and B, so AB can be block (one person). And now we have to arrange 9 person to 9 places. So it is $9!\times2$, where to need times two because of block can be either AB or BA.
(1) If there is one person between. Then we need a block which consists of three persons. A_B, where the middle person can be chosen in exactly $8$ ways. So we have to place one block  and 7 other people $\implies$ we need to place $8$ people. In the end $8!\times2\times8$ - the ways to arrange them, with one person between.
(2) If there are two persons between. Block consists of $4$ people: A_ _B.
Middle persons can be chosen in $8\times7$ ways. So we need to place $7$ persons. $7!\times2\times8\times7=8!\times2\times7.$
Overall There are $10!$ ways to place 10 people. 
So, the result is to sum $(0),(1), (2)$ and divide by $Overall$.
$$\frac{2\times9!+2\times8\times8!+8!\times2\times7}{10!}=\frac{24}{45}.$$ 
A: I would distinguish only between A,B and the others ($x$). So we do not distinguish between the others.
The number of possible no-between orders is $9\cdot 2$:
$abxxxxxxxx$
We just move 8 times $ab$ rightwards. And additionally we can exchange a and b.
The number of possible one-between orders is $8\cdot 2$
The number of possible two-between orders is $7\cdot 2$
And the (unconditional) ways of arranging $abxxxxxxxx$ is $\frac{10!}{8!\cdot 1!\cdot 1!}=9\cdot 10=90$
A: An interesting way is to imagine the line to be a circle.
Wherever $A$ is, there are $3$ spots clockwise for $B$
But we have to subtract cases where $A$ and $B$ are on opposite sides of $1$, viz.  
A-9-10-B / A-10-B / A-10-1-B / A-B-2 / A-1-B / A-1-2-B
Since only probability has been asked, we can compute $Pr = \dfrac{(10\cdot3 - 6)}{\binom{10}{2}} = \dfrac{24}{45}$
A: @calculus was on the right track, but didn't finish the problem.
You don't care about anyone else but A and B, and you don't care about the distinction between A and B.  An equivalent problem which is much easier to think with, is:
You have ten empty boxes in a row.  Each box can fit only one ball.  You have two balls.  You put each randomly in a box.  What are the odds that there are at most two boxes between your two balls?
In this problem, it is very straightforward.  There are 10 choose 2 ways to position the balls—10 x 9 / 2 = 45.
There are 9 sets of two boxes that have zero boxes in between—in other words, pairs of adjacent boxes.  There are 8 pairs of boxes with 1 box in between them, and 7 pairs of boxes with 2 boxes in between.
( 9 + 8 + 7 ) / 45 = 24/45, which is the answer.
(Danijel got the same answer, but I think this method is simpler because you don't have any numbers bigger than 90 at any point in the problem.)  ;)
