In how many ways can you write 'FOODIE' such that no letter remains in the same position it was before?
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.
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.
There are 4 ⋅ 3 = 1 2 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 combinations. In the second scenario, the other letter can be placed on all of remaining three positions - making total of 3 combinations. In the end, we fill remaining two places with Os. Hence, there are 1 2 × ( 4 + 3 ) = 8 4 ways to perform desired rearranging.
Python:
1 2 3 4 5 6 7 |
|
>84
you can add three backticks around the code to make it format correctly. (```CODE```)
Log in to reply
(you also need a newline between the code and any other text)
Thanks.
(Silly editor doesn't let me just post the 1-word response 'Thanks'.)
The formatting is much nicer if the ticks get their own line. :)
Why did u use a code
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.
The number of Derangement with n distinct objects and p identical objects D n , p is:
D n , p = ( p n ) k = 0 ∑ n − p ( k n − p ) ( − 1 ) k ( n − k ) !
For n = 4 and p = 2 we have
D 4 , 2 = 8 4
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 = ( p n ) D n − p , 0 where D n − p , 0 is the general derangement of n-p distinct items. The identity used follows from here
Problem Loading...
Note Loading...
Set Loading...
There are ( 2 4 ) = 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 ! ways of rearranging the numbers so that X is in its original position, 3 ! = 6 ways of rearranging the numbers so that Y is in its original position, and 2 ! = 2 ways of rearranging the numbers so that both X and Y are in their original position. Thus there are 6 + 6 − 2 = 1 0 ways of rearranging the numbers so that either X or Y is in its original position, and hence 4 ! − 1 0 = 1 4 ways of rearranging the numbers so that neither X nor Y is in its original position.
Thus there are 6 × 1 4 = 8 4 ways of rearranging the letters in FOODIE so that no letter is in its original position.