[Python-ideas] Fwd: Extremely weird itertools.permutations

Neil Girdhar mistersheik at gmail.com
Tue Oct 15 03:17:26 CEST 2013


Here are a couple people looking for the function that doesn't exist (yet?)

http://stackoverflow.com/questions/9660085/python-permutations-with-constraints/9660395#9660395
http://stackoverflow.com/questions/15592299/generating-unique-permutations-in-python


On Mon, Oct 14, 2013 at 4:52 PM, Bruce Leban <bruce at leapyear.org> wrote:

>
> On Sun, Oct 13, 2013 at 1:04 PM, MRAB <python at mrabarnett.plus.com> wrote:
>
>> Here's a use case: anagrams.
>>
>
> For what it's worth, I've written anagram-finding code, and I didn't do it
> with permutations. The faster approach is to create a dictionary mapping a
> canonical form of each word to a list of words, e.g.,
>
> {
>   'ACT': ['ACT', 'CAT'],
>   'AET': ['ATE', 'EAT', 'ETA', 'TEA']
> }
>
> This requires extra work to build the map but you do that just once when
> you read the dictionary and then every lookup is O(1) not O(len(word)).
> This canonical form approach is useful for other word transformations that
> are used in puzzles, e.g., words that are have the same consonants
> (ignoring vowels).
>
>
> --- Bruce
> I'm hiring: http://www.cadencemd.com/info/jobs
> Latest blog post: Alice's Puzzle Page http://www.vroospeak.com
> Learn how hackers think: http://j.mp/gruyere-security
>
> P.S. Yes, I know: if you play Scrabble, TAE is also a word.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/dDttJfkyu2k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131014/992f831f/attachment.html>


More information about the Python-ideas mailing list