1
$\begingroup$

By using the principle of inclusion/exclusion, I wanted to start with the total number of arrangements.

$S_0 = 5!$

Now I need to find the ones that are being counted more than once.

letting $S_1 = |12| + |23| + |34| + |45|$ and $S_2 = |123| + |234| + |345|$, $S_3 = |1234| + |2345|$, $S_4 = |12345|$

I think the general way to go about it would be $S_0 - S_1 + S_2 - S_3 + S_4$.

Is this the correct way to go about this problem? If so, I'm unsure of how to calculate the $S_x$

EDIT: progress update:

$S_0 = 5! = 120$

$S_1 = 4 * \binom{4}{1} * 3! = 96$

$S_2 = 3 * \binom{3}{1} * 2! = 18$

$S_3 = 4$

$S_4 = 1$

Therefore, I have $120 - 96 + 18 - 4 +1 = 39$ arrangements

  • 0
    please have a look to the final solution...2017-02-18

2 Answers 2

2

Call $A_k$ the set of permutations of $[n]$ where $k+1$ is right adjacent to $k$ then out of all $n!$ total permutations $$|A_k|= (n-1)!$$ but also it is true for any intersection $$|A_k\cap A_l|=(n-2)!$$ Because we may have, for example, 1-2 3 4-5 (3 objects to permute) or 1-2-3 4 5 (3 objects to permute). For every adjacency condition we add there is always 1 less object. Hence $$|A_k\cap A_l\cap A_m|=(n-3)!$$ etc.

In general there are $n-1$ sets $A_k$ hence $$S_1=\binom{n-1}{1}|A_k|\\S_2=\binom{n-1}{2}|A_k\cap A_l|\\\vdots$$

Therefore the desired count is, in general $$\text{valid permutations}=n!-\binom{n-1}{1}(n-1)!+\binom{n-1}{2}(n-2)!-\ldots +(-1)^{n-1}\binom{n-1}{n-1}1!$$ In your case $n=5$ so $$\text{valid permutations}=5!-\binom{4}{1}4!+\binom{4}{2}3!-\binom{4}{3}2! +\binom{4}{4}1!=53\qquad\blacksquare$$ A different method is to develop a recurrence for permutations of length $n$ with no cases where $k+1$ is right-adjacent to $k$, the required recurrence is $$a_n=(n-1)a_{n-1}+(n-2)a_{n-2}$$ with $a_1=1$ and $a_n=0$ for $n\le 0$.

This can be seen by noting that all valid permutations of $[n]$ can be formed by placing $n$ after all numbers except $n-1$ or at the start in all valid permutations of $[n-1]$. Or $n$ can go between two adjacent numbers $k$ and $k+1$ in all permutations of $[n-1]$ with exactly one right adjacency (there are clearly $(n-2)a_{n-2}$ of these because we treat the two adjacent numbers k-(k+1) as a single character and there are no more right adjacencies).

The sequence $a_n$ begins $$1,1,3,11,53,309,\ldots$$ It is possible to show that this sequence has an exponential generating function $$f(x)=\frac{e^{-x}}{(1-x)^2}$$

2

Consider $12$ as if it were a new character then you have to consider the strings having $12$ (the new character) and 3,4,5 (so length 4).

You have $\binom{4}{1}$ ways of placing the $12$ symbol and then $3!$ for placing the remaining characters.

So in total:$\binom{4}{1}\cdot 3!= 24$

Of cours it is the same for $23$, $34$ or $45$.

Hence $S_1=4\cdot 24 = 96$.

You perform similar calculations for the other combinations...

Edit after progress:

$S_2$ is the possibility to make a string with two forbidden strings, say $12$ and $23$. Therefore, you have 2 two symbols forbidden strings and the remaining symbol. They can be placed in $3!$ ways. Finally you have $\binom{4}{2}$ ways of choosing the two symbols forbidden pair. Therefore:

$S_2=3!\cdot\binom{4}{2}=36$

Now $S_3$ concerns the patterns $123$, $234$ and $345$. If you consider the pattern as a single character then you have $3!$ ways to arrange them together with the two remaining symbols. Hence $S_3=3\cdot 3!=18$

$S_4$ is concerned with the patterns $1234$ and $2345$. You have $2$ possibilities for each one. Hence $S_4=4$

$S_5=1$ of course.

So the final result is 45=120-96+36-18+4-1.

This number is wrong. The following Sage program confirms that the right value is 53. But What was wrong in my reasoning?

This is also confirmed by this small Sage program:

Filtered=[]
MyList=Permutations(['1', '2', '3','4','5']).list()
skip=0
for i in MyList:
    for j in range(1,5):
        if ((i[j-1]=='1' and i[j]=='2') or (i[j-1]=='2' and i[j]=='3') or (i[j-1]=='3' and i[j]=='4') or (i[j-1]=='4' and i[j]=='5')):
            skip=1
    if(skip==0):
        Filtered += [i]
    else:
        skip=0
len(Filtered)  

Here is the list of all possible patterns (obtained with Sage):

    [['1', '3', '2', '5', '4'],
 ['1', '3', '5', '2', '4'],
 ['1', '3', '5', '4', '2'],
 ['1', '4', '2', '5', '3'],
 ['1', '4', '3', '2', '5'],
 ['1', '4', '3', '5', '2'],
 ['1', '5', '2', '4', '3'],
 ['1', '5', '3', '2', '4'],
 ['1', '5', '4', '3', '2'],
 ['2', '1', '3', '5', '4'],
 ['2', '1', '4', '3', '5'],
 ['2', '1', '5', '4', '3'],
 ['2', '4', '1', '3', '5'],
 ['2', '4', '1', '5', '3'],
 ['2', '4', '3', '1', '5'],
 ['2', '4', '3', '5', '1'],
 ['2', '5', '1', '4', '3'],
 ['2', '5', '3', '1', '4'],
 ['2', '5', '4', '1', '3'],
 ['2', '5', '4', '3', '1'],
 ['3', '1', '4', '2', '5'],
 ['3', '1', '5', '2', '4'],
 ['3', '1', '5', '4', '2'],
 ['3', '2', '1', '5', '4'],
 ['3', '2', '4', '1', '5'],
 ['3', '2', '5', '1', '4'],
 ['3', '2', '5', '4', '1'],
 ['3', '5', '1', '4', '2'],
 ['3', '5', '2', '1', '4'],
 ['3', '5', '2', '4', '1'],
 ['3', '5', '4', '2', '1'],
 ['4', '1', '3', '2', '5'],
 ['4', '1', '3', '5', '2'],
 ['4', '1', '5', '3', '2'],
 ['4', '2', '1', '3', '5'],
 ['4', '2', '1', '5', '3'],
 ['4', '2', '5', '1', '3'],
 ['4', '2', '5', '3', '1'],
 ['4', '3', '1', '5', '2'],
 ['4', '3', '2', '1', '5'],
 ['4', '3', '2', '5', '1'],
 ['4', '3', '5', '2', '1'],
 ['5', '1', '3', '2', '4'],
 ['5', '1', '4', '3', '2'],
 ['5', '2', '1', '4', '3'],
 ['5', '2', '4', '1', '3'],
 ['5', '2', '4', '3', '1'],
 ['5', '3', '1', '4', '2'],
 ['5', '3', '2', '1', '4'],
 ['5', '3', '2', '4', '1'],
 ['5', '4', '1', '3', '2'],
 ['5', '4', '2', '1', '3'],
 ['5', '4', '3', '2', '1']]

Ok now this is the end ;-)

  • 0
    so okay I calculated $S_2 = $3 * binom{3}{1} * 2!$, $S_3 = 4$, and $S_4 = 1$ and I got a total of 39 arrangements2017-02-17
  • 0
    Sorry I made a mistake... give me five minutes to edit...2017-02-17
  • 0
    if that is the problem? then what about in $S_2$ where 12 and 23 occur in 123 as well? or maybe I didn't understand your reasoning? and in $S_3$ 12 ,23, and 34 occur? I could just not be interpreting it correctly...2017-02-17
  • 0
    Finally I think that your $S_2$ is ok. I will re-edit. Sorry but I'm a bit tired ;-)2017-02-17
  • 0
    no worries! i'm appreciating all the help2017-02-17
  • 0
    Now have to go. I will post the solution tomorrow morning if you didn't find in the meanwhile. Cheers2017-02-17
  • 0
    no this was good I think I got it now. thanks!2017-02-17
  • 0
    Ok finally @N .Shales gave the good solution !2017-02-18
  • 0
    I was not totally convinced by the other solution so finally I performed all the calculations again... and found some surprise ;-)2017-02-18
  • 0
    There are some valid permutations not present in your list: 25431, 24351, 31542, 35142, 42153, 42513, 51324, 53124. This add to your 45, making 53.2017-02-19
  • 0
    @N.Shales You are right! Indeed, I wrongly indexed the search in the Sage program. But what is wrong in my reasoning?2017-02-19
  • 0
    In order to apply PIE it is important to define sets. Think of a Venn diagram with 5 overlapping sets in this case, what are they? In your method you have implied that the sets are defined by forbidden strings so that, for example, one set has all permutations with (at least) the forbidden string 1-2 and another with the forbidden string 2-3 etc. But when applying PIE you have ignored the sets as defined. E.g. In $S_2$ you add strings such as 1-2 3 4-5 and in $S_3$ subtract strings like 1-2-3 4 5 which are both 2-intersections of the defined sets so these should both be added.2017-02-19
  • 0
    Hmm... tried to find "easier way" but as usual "easier" does not rime with correct...2017-02-19