Find 6-letter words that are hidden (embedded) within
Pancho
Pancho.Jones at proton.me
Fri Feb 24 13:59:18 EST 2023
On 24/02/2023 18:34, Hen Hanna wrote:
>
> i just wrote a program, which...
> within [FunFunPython]
> finds: (funny, futon, python)
>
> ( 5- and 6- letter words )
>
>
> (my program uses a Trie, but is pretty simple)
>
>
>
> Maybe someone would show me
> how it's done using itertools, Permutations, etc.
>
> Wouldn't it get too slow for Letter-Seeds longer than 11 letters or so?
>
For performance, generally you sort the characters in a word to create a
new word (character list) and compare the sorted character lists (which
you can use a string for). Two anagrams will produce the same sorted
character list.
The problem with going through all permutations is that the number of
permutations tends to grow exponentially, so that is why you sort first.
So first take an English dictionary and build a python dictionary with
the key being the character sorted list and the value being a list of
the English words that produce the sorted list, aka anagrams.
You then sort your specific word and test each subset of this sorted
word (each combination of characters) against your python anagram
dictionary.
More information about the Python-list
mailing list