Faster way to do this?

Paul Rubin http
Wed May 21 02:16:23 EDT 2003


Freddie <oinkfreddie at oinkmadcowdisease.oinkorg> writes:
> Another, quite a bit faster method. Would generating a list of all
> possible words, then looking for them as dictionary keys be any
> faster? I can't actually work out how to generate such a list :\
> From the input ('m', 'o', 'o') I want ('m', 'mo', 'mo', 'moo', 'o',
> 'om', 'oo', 'oom', 'o', 'om', 'oo', 'oom') in any sort of
> order. Well, maybe without duplicates :)

Well, if you only want to run the program on one word, generating that
list is probably slower than linearly searching the dictionary.  If
you want to run it on lots of words, then yes, precomputation can help
you.




More information about the Python-list mailing list