Derangement with repetition

In how many ways can you write 'FOODIE' such that no letter remains in the same position it was before?


The answer is 84.

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.

4 solutions

Mark Hennings
Aug 12, 2019

There are ( 4 2 ) = 6 \binom{4}{2}=6 ways of placing the two Os in new positions. For each such position, there are two of the other four letters whose original position has been chosen, and so can go in any of the remaining places, while the other two letters could, but must not, go in their original positions.

Let us count the number of ways of rearranging XYZW such that neither X nor Y is in its original position. There are 3 ! 3! ways of rearranging the numbers so that X is in its original position, 3 ! = 6 3!=6 ways of rearranging the numbers so that Y is in its original position, and 2 ! = 2 2!=2 ways of rearranging the numbers so that both X and Y are in their original position. Thus there are 6 + 6 2 = 10 6+6-2=10 ways of rearranging the numbers so that either X or Y is in its original position, and hence 4 ! 10 = 14 4! - 10 = 14 ways of rearranging the numbers so that neither X nor Y is in its original position.

Thus there are 6 × 14 = 84 6 \times 14 = \boxed{84} ways of rearranging the letters in FOODIE so that no letter is in its original position.

Second method: Take two Os as O2 and O3 (numbers denoting initial positions) . Now using PIE and derangements we can find that there are 168 ways in which position 2 and position 3 are not containing any O . Now since the two letters are similar we have actually double counted the cases. ( Since interchanging positions of O denotes same word )And thus for every 1 combination we have actually counted 2 combinations , and hence divide by two.

Hitesh Yadav - 4 months, 3 weeks ago
Uros Stojkovic
Aug 14, 2019

There are 4 3 = 12 4\cdot 3 = 12 ways to fill two O's places with two of the 4 remaining letters. After that, we are left with two O's and two other letters . Now, one of those two letters can be placed either on one of the free places (which came to be free because we've used letters from these positions for filling O's positions) or on the place of the other letter of the two. In the first scenario, after placing one letter on one of two free places, there are two possible places for the other letter - second free place or the place of the first letter - making total of 4 4 combinations. In the second scenario, the other letter can be placed on all of remaining three positions - making total of 3 3 combinations. In the end, we fill remaining two places with Os. Hence, there are 12 × ( 4 + 3 ) = 84 12\times (4+3) = 84 ways to perform desired rearranging.

Richard Desper
Aug 12, 2019

Python:

1
2
3
4
5
6
7
F = ["F","O","O","D","I","E"]
L = list(itertools.permutations(F))  #all permutations of this list.
count = 0
for word in L:
    if (derange(F,word)):  #defined appropriately
        count +=1   #count is double-counting, since the iterator treats the two 'O's as distinct characters  
return(count // 2)

>84

you can add three backticks around the code to make it format correctly. (```CODE```)

Mike Pannekoek - 1 year, 10 months ago

Log in to reply

(you also need a newline between the code and any other text)

Mike Pannekoek - 1 year, 10 months ago

Thanks.

(Silly editor doesn't let me just post the 1-word response 'Thanks'.)

Richard Desper - 1 year, 10 months ago

The formatting is much nicer if the ticks get their own line. :)

Richard Desper - 1 year, 10 months ago

Why did u use a code

sathvik reddy - 1 year, 10 months ago

Log in to reply

Because coding is easy while counting all the sub-cases of a permutation problem isn't very interesting to me. Also, because I'm transitioning from C to Python and, while I knew how to cycle through permutations in C I didn't know how to do it in Python, and it's a useful thing to know how to do.
The code would generalize easily to any word, whereas an ad hoc argument for "Foodie" alone wouldn't.

Richard Desper - 1 year, 10 months ago
Gabriel Benício
Sep 2, 2019

The number of Derangement with n distinct objects and p identical objects D n , p D_{n, p} is:

D n , p = ( n p ) k = 0 n p ( n p k ) ( 1 ) k ( n k ) ! \displaystyle D_{n,p}={n \choose p}\sum_{k=0}^{n-p} {n-p \choose k}(-1)^k(n-k)!

For n = 4 n=4 and p = 2 p=2 we have

D 4 , 2 = 84 D_{4, 2}=84

just to give the readers a better idea about the identity you used,

We have a list of p identical objects in set P and n distinct objects in set Q. The p identical objects should go the the position of elements in Q(otherwise they will contradict the derangement idea). So, we select p elements out of n elements in Q and view this problem as derangement problem of (n-p) distinct elements. D n , p = ( n p ) D n p , 0 D_{n,p}=\binom{n}{p}D_{n-p,0} where D n p , 0 D_{n-p,0} is the general derangement of n-p distinct items. The identity used follows from here

Mayank Chaturvedi - 9 months, 3 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...