Where to start: which set of N letters makes the most words?

I am having trouble approaching non-brute force to solve this problem. I was wondering: what set of N letters can I use to create most of the words from this dictionary? Letters can be used any number of times.

For example, for N = 3, we can have EST to give words like TEST and SEE, etc.

Searching the Internet, I found some answers (for example, those listed above for EST), but no description of this approach.

My question is: what known problems are similar to this or what principles should be used to solve this problem?

NOTE. I know that it is not necessarily true that if EST is best for N = 3, then ESTx is best for N = 4. That is, you cannot just add a letter to the previous solution.

In case you are interested, this question came to mind because I was wondering that a set of 4 ingredients can make most cocktails, and I started looking for it. Then I realized that my question was specific, and so I decided that the question with this letter is the same type of problem, and started looking for it as well.

+4
source share
2 answers

For each word in the dictionary, sort the letters and delete duplicates. Let it be the skeleton of the word. For each skeleton, count how many words it contains. Let it be its frequency. Ignore all skeletons larger than N.

- 1 , EST E, S, T, ES, ET, ST. N . .

O (2 ** N * D), D - .

: N ( ), numbet O (2 ** N * C (L, N)), L (, 26 ).

+2

, , -, . !

  • N , , . L - .
  • : 'test' -> {'e','s','t'}
  • 1 N , , , .
  • - 1 N , 1 .
  • , ! (unique_cut_list) N. , , - - N.
  • unique_cut_list, - ( ), , . , - N .
  • , . - , .

1 + 2N 1-5, 6 (2 ^ N) -1 ( ). O (2NL + L * 2 ^ N), O (L * 2 ^ N). , N !

0

Source: https://habr.com/ru/post/1658242/


All Articles