Permutations of Undertale

The image above shows one of the possible interesting permutations of the word undertale . All of the letters are dearranged except for the last.

How many permutations of the word undertale are there such that there is only one letter on the same position?


The answer is 67676.

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.

2 solutions

Mark Hennings
Jun 28, 2020

Suppose that one of the Es is in the correct place. There are 2 2 Es that could be chosen, and there are d 8 = 14833 d_8 = 14833 arrangements of the other 8 8 letters so that none of these are in the correct place (here d n d_n is the number of derangements of n n symbols).

Suppose that one of the other letters is in the correct place. Then the two Es must go in the places of two different letters again. There are 7 7 choices for the letter that will be fixed, and ( 6 2 ) \binom{6}{2} choices for the two letters where the two Es will go. Suppose that, for example, letter D is fixed, and the two Es go in the L and T places. Then we have to arrange the letters L,T,A,R,U,N in the E,E,A,R,U,N places, so that none of A,R,U,N are in their correct place. Let A 1 , A 2 , A 3 , A 4 A_1,A_2,A_3,A_4 be the number of arrangements with A , R , U , N A,R,U,N (respectively) in its correct place. Then A i = 5 ! |A_i| = 5! for all 1 i 4 1 \le i \le 4 , A i A j = 4 ! |A_i \cap A_j| = 4! for all 1 i < j 4 1 \le i < j \le 4 , A i A j A k = 3 ! |A_i \cap A_j \cap A_k| = 3! for all 1 i < j < k 4 1 \le i < j < k \le 4 and A 1 A 2 A 3 A 4 = 2 ! |A_1 \cap A_2 \cap A_3 \cap A_4| = 2! . By the Inclusion-Exclusion Principle, we deduce that A 1 A 2 A 3 A 4 = 4 × 5 ! 6 × 4 ! + 4 × 3 ! 2 ! = 358 |A_1 \cup A_2 \cup A_3 \cup A_4| = 4 \times 5! - 6 \times 4! + 4 \times 3! - 2! \; = \; 358 and hence there are 6 ! 358 = 362 6! - 358 = 362 arrangements of L,T,A,R,U,N in the E,E,A,R,U,N places so that none of A,R,U,N are in the correct place.

Thus there are 2 × d 8 + 7 × ( 6 2 ) × 362 = 67676 2 \times d_8 + 7 \times \binom{6}{2} \times 362 = \boxed{67676} rearrangements of UNDERTALE so that exactly one letter is in the correct place.

Sorry, but I don’t understand how you got d 8 d_8 . Could you explain more on that part? Thank you!
BTW, I’m looking for a pattern for d n d_n as well, with d 1 = 0 , d 2 = 1 , d 3 = 2 , d 4 = 9 d_1=0,d_2=1,d_3=2,d_4=9 but I can’t find one 😅

Jeff Giff - 11 months, 2 weeks ago

Log in to reply

The number d n d_n of derangements of n n symbols has the standard formula d n = n ! j = 0 n ( 1 ) j j ! d_n \; = \; n!\sum_{j=0}^n \frac{(-1)^j}{j!} which can be proved using the Inclusion-Exclusion Principle (rather like the way I obtained the number 362 362 in my proof above). This result leads to the interesting observation that the proportion of derangements is d n n ! = j = 0 n ( 1 ) j j ! e 1 n \frac{d_n}{n!} \; = \; \sum_{j=0}^n \frac{(-1)^j}{j!} \; \to \; e^{-1} \hspace{2cm} n \to \infty

Mark Hennings - 11 months, 2 weeks ago

Log in to reply

Oic! Thanks for telling me :)

Jeff Giff - 11 months, 2 weeks ago

Log in to reply

@Jeff Giff Also, it's worth noticing that derangements also has a reclusive formula: d(n)=(n-1)(d(n-1)+d(n-2))

Alice Smith - 11 months, 2 weeks ago

d n = (n-1) × (d (n-1) + d (n-2)) for n > 3. I just used it recursively, but you can find the direct equation for d n from this pretty easily. (Sorry about the bad formatting, I can't get it to past in or type in properly).

I got the above equation by doing the following (for re-ordering a list of numbers 1,2,...,n): 1. There are (n-1) ways to pick the number in the first position. Call it x. 2. There are d (n-1) ways to arrange the rest of the numbers if you treat 1 as if it is x (it can't be placed in the xth postion). 3. Now place 1 at the xth position. Then there are n-2 numbers left to order, so you get d (n-2) ways to order these. 4. Sum these together for the (n-1) possible x, and you get the above recursion.

(My problem with solving came from an assumption that the numbers below the letters in UNDERTALE signified that the Es where distinct).

Meenakshi McNamara - 11 months ago
Finnley Paolella
Jun 29, 2020

For everyone who is too lazy to do the calculations:

1
2
3
4
5
6
7
8
from itertools import permutations
def count(word):
    s = set()
    for p in permutations(word):
        if sum([p[i]==word[i] for i in range(len(word))]) == 1:
            s.add(p)
    return len(s)
count('undertale')

67676

Do you need to check if p p is in s s or not? Isn't s s a set?

Atomsky Jahid - 11 months, 2 weeks ago

Log in to reply

Yes you are right! I edited my post, thanks.

Finnley Paolella - 11 months, 2 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...