Five people are standing in a line. In how many possible ways can they be rearranged such that no two people that were originally next to each other remain next to each other in the new arrangement?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Oh wow, that's a an interesting interpretation!
Nice solution. As for a general formula, I agree that there probably isn't a closed-form formula, but I would suggest that this OEIS sequence is more representative of this specific problem.
Log in to reply
The sequence that you linked to is " such that ∣ p ( i ) − p ( i + 1 ) ∣ is in { 2 , 3 , 4 , 5 } ", so that will not work for n > 7 .
I used the principle of inclusion and exclusion. From all the possibilities of arranging ABCDE (5!), I alternatively subtracted and added the possibilities of having 1,2,3 and 4 original connections.
Let's assume the original order of pots to be “ABCDE”
There are 14 orders satisfying Manoj ’s condition ,they are:
ACEBD ADBEC
BDACE BDAEC
BECAD CADBE
CAEBD CEADB
CEBDA DACEB
DBEAC DBECA
EBDAC ECADB
Well I did it by observation, but I desire a better and analytical approach towards this question if it was for 9 pots or so. Any solution posted will be appreciated .
Interesting generalization. I wonder if a recurrence relation would help this. I'm not looking forward to attempting to do it by PIE.
Log in to reply
Wish You a Merry Christmas and a Happy New Year
Seing your solution makes me confuse. I think i missunderstood the problem. Can you make it more detail with the words?
Log in to reply
Dude I'm sorry, coz I've tried to put forth the question in a way that it is the shortest and yet no information is witheld from the reader.
But if you can specifically relate to me your problem, maybe I'll still be able to help you.
Wish You a Merry Christmas and a Happy New Year
Were the number of arrangements asked in question? Question was not clear.
Log in to reply
The question clearly said "Calculate the number of possible ways", but even so, since you asked for it I'llchange the wordings for you . :) Wish You a Merry Christmas and a Happy New Year .
Consider the people to be ABCDE.
1)Putting A in the Center, we have 2 pairs CD and DE and their reversals (DC and ED) that can go around A. So that's 4 possible ways.
2)Same for the other extreme letter E in the center. We have 2 pairs AB and BC and their reversals (BA and CB) that go around E. Another 4 ways.
3)Putting B in center we have only pair DE and its reversal ED around it so 2 more.
4)Putting C in center we have only pair AE and its reversal EA around it so 2 more.
5)Putting D in center we have only pair AB and its reversal BA around it so 2 more.
Total 14 ways.
In response to Satyen Nabar : So sir how would you approach this problem if u had 9 or 10 flower pots instead of 5 or could you solve this problem for n flower pots .
I mean instead of taking cases can we think of generating a function here . Thanks for the same ,
Log in to reply
I tried but honestly cant find a way...
Log in to reply
No prob sir, thanks for the same. :)
Wish You a Merry Christmas and a Happy New Year
The recursion is listed at OEIS --- https://oeis.org/A002464
I used numbers 1,2,3,4,5 instead of colors (or names), and wrote a simple program. It found these 14 ways:
13524 14253 24135 24153 25314 31425 31524 35142 35241 41352 42513 42531 52413 53142
Here is the program in JustBasic:
for a=1 to 5
for b=1 to 5: if b=a then [nb]
for c=1 to 5: if c=a or c=b then [nc]
for d=1 to 5: if d=a or d=b or d=c then [nd]
for e=1 to 5: if e=a or e=b or e=c or e=d then [ne]
c1=(abs(a-b)>1): c2=(abs(b-c)>1) : c3=(abs(c-d)>1): c4=(abs(d-e)>1)
if c1 c2 c3*c4 then print a;b;c;d;e
[ne] next e
[nd] next d
[nc] next c
[nb] next b
[na] next a
All it is doing is 1- create the first of all permutations of 1,2,3,4,5; 2- ensure that it does not have adjacent numbers; 3- print it; 4-create next permutation
Note: Adjacent numbers have absolute value of their difference equal to 1.
I just counted the permutations. Labeling the people A, B, C, D, E, we start with A:
A cannot be next to B, so we have A, C or A, D, or A, E. We take the first of these, A, C, and continue:
C cannot be next to B or D, so we have A, C, E.
E cannot be next to D, so we have one complete permutation: A, C, E, B, D.
Using this process, I found two permutations beginning with A, three beginning with B, And four beginning with C. To make it easier, beginning with E gives the same result as beginning with A, and beginning with D gives the same result as beginning with B.
Therefore, we have 2+2+3+3+4= 14 possible permutations where no people are next to someone they were next to initially.
Disclaimer: I am a sophomore in college and have not taken any classes in discrete mathematics or graph theory yet. I know there are easier and more ubiquitous ways to solve this problem, but this is what I could come up with knowing only the basics of permutations. Hope it helps anyone at my same level!
ABCDE. ACE could have any order. 3! = 6. I cant place B or D close to C, so: - if C is in the middle (2 possibilities), I can put BD in front, DB at the end or one at ths start and one at the end. That makes 6 possibilities. - if C is at the beginning, BD can go at the end (1 poss.) or between AE (1 poss). - 4*2=8 possibilities. 6+8=14
Trying to generalizing..... If there are 3 pots -> 0 If there are 4 pots -> 1 If there are 5 pots -> 14
I can't find an easy way to count them if they're 6....they're many :(
Thanks for trying dude.
Wish You a Merry Christmas and a Happy New Year
Problem Loading...
Note Loading...
Set Loading...
A probably easier way to imagine this, instead of counting the number of permutations where no two adjacent elements are consecutive, is to count the number of Hamiltonian paths in the following graph: a complete graph of n vertices, but one Hamiltonian path (with n − 1 edges) have been removed. In the left diagram, we remove the red Hamiltonian path from the complete graph K 5 .
The good thing for n = 5 is that the graph is isomorphic to one that is way easier to discern, to the right. There are two classes of paths:
In total there are 1 4 paths.
There doesn't seem to be any obvious pattern for the generalization. However, OEIS says the following recursion is true: a 0 = a 1 = 1 , a 2 = a 3 = 0 , and a n = ( n + 1 ) a n − 1 − ( n − 2 ) a n − 2 − ( n − 5 ) a n − 3 + ( n − 3 ) a n − 4 for all n ≥ 4 . Anyone interested on proving it?