0
$\begingroup$

I'm a security researcher, in my research i'm stacked on an algorithm which can be solve by using maths. Please help me to solve this Problem.

Q.) How many words we will get in a dictionary? Below Conditions should be follow in creation of this dictionary: a.) Word length should be 15 b.) We have a-z alphabets (all in lower case) and 0-9 digits or we can say total 36 characters c.) all words should be random d.) same characters should not come trice. There should be a distance of at-least on charter in it. For example: aaa is not allowed in a word but aa1a is allowed.

Some sample Words: 66motk2tiblxduo o9myi8tmielruu5 9oeczw87pivbj16 q1humqkeuw8eoj4 2qo3bghfz1rtw8p mfeh6yg4evy5iz6 cilir3ffo9i6g38 7z4lg2fujposmoe

If i'm ignoring point d then calculation is very simple P(n,r)=P(36,15) =7281003461233582080000 http://www.calculatorsoup.com/calculators/discretemathematics/permutations.php?n=36&r=15&action=solve

But I have to include point d to get the exact calculation.

I will be really thankful to you if you help me to calculate the exact answer.

  • 0
    I'd suggest you rewrite your question to this (let me know if I may edit your question accordingly): How many different words of length $15$ can be generated using a dictionary consisting of $36$ different letters, when $k$ of the letters must not be written thrice in a row in a word (e.g., if 'a' is one of the $k$ letters, then 'aaa' is not allowed in a word, but 'aa1a' is allowed)? Without the last condition, there are $P(36,15)$ possible words, but what is the number with the condition?2017-02-07
  • 2
    What does this have to do with complex analysis?2017-02-07
  • 0
    Sorry, but $P(n,r)$ is the number of permutations (i.e., strings without repetitions) of $r$ objects taken from a set of $n$, __not__ the number of $15$-strings, which is $36^{15}$. From the examples and the question itself, it’s clear that you allow repetitions. Also, it is not clear what you mean by “all words should be random”. How to count “non-random” words? Reject all strings with substrings appearing in an English dictionary? Accept only strings with a given character frequency distribution?2017-02-07

2 Answers 2

1

Denote by $S_n$ the number of admissible strings of length $n$. Then $S_1=36$, $S_2=36^2=1296$. Furthermore the $S_n$ satisfy the following recursion: $$S_n=35 S_{n-1}+35 S_{n-2}\qquad(n\geq3)\ .$$ Proof. Any admissible string of length $n\geq3$ ends with two different letters or two equal letters. It is obtained by appending one letter to an admissible string of length $n-1$ or a pair of two equal letters to a string of length $n-2$, where in both cases we may choose from $35$ letters.$\quad\square$

The resulting problem can be handled with the "Master Theorem" on difference equations.

0

After Christian Blatter’s perfect answer, nothing else can be added, but the actual answer. The easiest way to compute it is by simple iteration with appropriate software (the OP is a programmer, no problem in that).

$$ S_{15} = 218920088066669265937500 $$