1

From $n$ amount of things, if we take $r$ things in which $2$ special things have to be selected, how many ways can we arrange the things so that the two special things are not in the first or last of the rows?
I want to solve this problem by finding out the (total ways - ways to have the special things at first or last).

I found total ways to be

$$\frac{(n-2)!(2nr-r^2-r)}{(n-r)!}$$

But the problem becomes an algebraic mess from there. I would be forever grateful if anyone provides a solution using the total ways - first or last formula.

Edit : I have found the total amount of ways to be $$\frac{r(r-1)(n-2)!}{(n-r)!}$$ This is because the $1$st special thing can be sorted into $r$ positions , the $2$nd special thing can be sorted into $(r-1)$ positions and the other $(n-2)$ things can be sorted into $(r-2)$ positions.

Edit(2) : Guys I think I got it. The total ways can be calculated by $$\frac{r(r-1)(n-2)!}{(n-r)!}$$

Now we calculate the number of ways the special letters are at $1$st or last of the row (we name this process point two)

Now, we consider the following cases

Case : $1$

If the $1$st special letter is at the 1st of the row, the $2$nd special letter has $(r-1)$ places to be so in this case, the $(n-2)$ other things/letters have $(r-2)$ places to be in

So in this case , Number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$

Case: $2$

If the 1st special letter is at the last of the row it follow the same process as case 1 . So the number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$

Case: $3$

In this case , we consider the $2$nd special letter being in the first of the row . The process clearly remains the same as Case 1

So, Number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$

Case: $4$

In this case we consider $2$nd special letter being in the last of the row . The process clearly remains the same as case 1

So, Number of ways = $$\frac{(r-1)(n-2)!}{(n-r)!}$$

Total number of ways(In these 4 cases) = Case 1 + Case 2 + Case 3 + Case 4 =$$\frac{4(r-1)(n-2)!}{(n-r)!}$$

Some of these cases overlap since when suppose $1$st special letter is at the first of the row , the $2$nd special letter can be at the last of the row . So in this scenario , Case 1 and Case 4 overlap . In order to get rid of this overlapping we consider the following cases

Case $5$

This is the case of the $1$st special letter being in the $1$st of the row and the $2$nd special letter being at the last of the row. Since these two are fixed we have $(n-2)$ other things which can go in $(r-2)$ places. So number of ways = $$\frac{(n-2)!}{(n-r)!}$$

Case $6$

This is the case of the $2$nd special letter being in the $1$st of the row and the $1$st special letter being in the last of the row . This follows the process of case 5 . So number of ways = $$\frac{(n-2)!}{(n-r)!}$$

Adding these two cases we get the total number of ways the cases can overlap = $$\frac{2(n-2)!}{(n-r)!}$$

We subtract these two cases from the first 4 cases =

$$\frac{(4r-6)(n-2)!}{(n-r)!}$$

This is Point $2$ , So we subtract this from the total number of ways and get the result of =

$$\frac{(r-2)(r-3)(n-2)!}{(n-r)!}$$

This is what the question asked

  • Doesnt "r" (the number of things that can be in a row) play a role in here? – Iftekhar Alam Bhuiyan Jan 18 '23 at 20:54
  • I have tried again and found out the total ways can be calculated by r(r-1)x(n-2)!/(n-r)! ( I might be wrong but here is my logic). Since there are two special things the 1st one can go in r different spots and the 2nd one can go in (r-1) different spots then the rest of them can go in (r-2) different spots so I applied the formula n!/(n-r)! For (n-2) things and (r-2) spots – Iftekhar Alam Bhuiyan Jan 18 '23 at 21:07
  • I am the OP . there are r positions in the row. – Iftekhar Alam Bhuiyan Jan 19 '23 at 10:22
  • @user2661923 Oh I see, there is an additional task involving choosing the $r$ things from the $n$ things I suppose. I will delete my comment soon – Joseph Harrison Jan 19 '23 at 13:45

1 Answers1

1

The posting's use of the fraction $~\displaystyle \frac{(n-2)!}{(n-r)!}~$ suggests that all $n$ items are to be considered distinct from each other, and that (therefore), the order that the items appear in the row is pertinent.

I am assuming that there are exactly $r$ positions in the row, where the $r$ items are to be placed.

My approach is to take the distribution in stages, using Inclusion-Exclusion to polish the answer. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.


First, you have to select $(r-2)$ non-special items to accompany the $2$ special items.

This can be done in

$$\binom{n-2}{r-2} ~~\text{ways}. \tag1 $$

Assume that $(r-2)$ non-special items have been selected.

For any set $E$ with a finite number of elements, let $|E|$ denote the number of elements in the set $E$.

Let $S$ denote the set of all distributions of the $[(r-2) + 2]$ selected items, where the restriction on where the two special items are placed is ignored.

Let $S_1$ denote the subset of $S$, where the 1st special item occurs in either the first or last position.

Let $S_2$ denote the subset of $S$, where the 2nd special item occurs in either the first or last position.

Then, the desired computation, omitting the factor in (1) above, will be

$$|S| - |S_1 \cup S_2|.$$

By inclusion-Exclusion, this equals
$|S| - |S_1| - |S_2| + |S_1 \cap S_2|.$

Then:

  • $|S| = r!.$

  • $|S_1| = 2 \times (r-1)!$.
    That is, the 1st special item can go in either the first position, or the last position. Once the 1st special item is set, there are $(r-1)!$ ways of positioning the other $(r-1)$ items, which includes the 2nd special item.

  • $|S_2| = 2 \times (r-1)!$.
    This follows by the same analysis as in the previous bullet point.

  • $|S_1 \cap S_2| = 2! \times (r-2)!.$
    Here, it is being assumed that both the 1st special item and the 2nd special item are in violation. There are $(2!)$ ways of arranging these two special items in the first/last places on the row. Then, there are $(r-2)!$ ways of placing the remaining $(r-2)$ items.


Putting all of this together with the initial factor in (1) above gives a final computation of

$$\binom{n-2}{r-2} \times \left\{ ~[r!] - [4 \times (r-1)!] + [2 \times (r-2)!] ~\right\} $$

$$= \binom{n-2}{r-2} \times [(r-2)!] \times \left\{ ~[r(r-1)] - [4 \times (r-1)] + [2] ~\right\} $$

$$= \frac{(n-2)!}{(n-r)!} \times [r^2 - 5r + 6].$$

This answer agrees with the final calculation in the posted question.

user2661923
  • 35,619
  • 3
  • 17
  • 39
  • I agree with your process. Thanks a lot for helping me out. What I would like to ask is if there is any problem with the process I answered in . If their is any problem with the process there let me know kindly . Again , thanks a lot! – Iftekhar Alam Bhuiyan Jan 19 '23 at 10:21
  • @IftekharAlamBhuiyan I found your analysis too disorganized for me to routinely diagnose. Please edit your final analysis into one organized section, with judicious use of line breaks, via <br> and paragraph breaks. Then, give me another flagging comment, and I will re-examine your analysis. – user2661923 Jan 19 '23 at 14:30
  • @user26619231 Can you check if its better now? I tried to make it readable . I do not understand what line breaks are. But I think this is much better than before. Can you check it now ? I would be pleased if you could give me some ideas aoout how to make my writing bettter – Iftekhar Alam Bhuiyan Jan 19 '23 at 16:01
  • 1
    @IftekharAlamBhuiyan Your posting is much easier to read now. I have double checked your analysis, and it is totally accurate and valid. It is still moderately confusing, but easier for someone to reverse engineer your intent. Consider, if you were totally unfamiliar with the problem, and you had to read analysis, which analysis would be easier to read: yours or mine. A line break, which is triggered by <br> is a way of forcing the interface to start a new line. ...see next comment – user2661923 Jan 19 '23 at 16:24
  • 1
    @IftekharAlamBhuiyan In my answer, an example where I wanted the paragraph to continue, but I also wanted to force a line break, is : - $|S_1| = 2 \times (r-1)!$. <br> That is, the 1st special item can go in either the first position, or the last position. – user2661923 Jan 19 '23 at 16:26