goto

Steven D'Aprano steve at REMOVETHIScyber.com.au
Tue Jul 19 13:43:28 EDT 2005


On Tue, 19 Jul 2005 11:29:58 -0400, rbt wrote:

>> It should not really come as a shock that the same fellow who came up with a brilliant efficient way
>> to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto.
>> 
>> Coming next from rbt: "Pointer arithmetic in python ?".
>> 
>> George
>> 
>> 
> 
> I have moments of brilliance and moments of ignorance. You must admit
> though, that was a unique way of generating permutations... how many
> other people would have thought of that approach? It did solve my
> problem ;)

Sorry rbt, but your algorithm isn't unique, nor was it clever, and in fact
your implementation wasn't very good even by the undemanding requirements
of the algorithm. It is just a minor modification of bogosort (also known
as "bozo-sort") algorithm:

http://en.wikipedia.org/wiki/Bogosort

I quote:

"...bogosort is 'the archetypal perversely awful algorithm', one example
of which is attempting to sort a deck of cards by repeatedly throwing the
deck in the air, picking the cards up at random, and then testing whether
the cards are in sorted order."

Bogosort is nothing to be proud of, except as a joke. Put it this way: of
all the many ways to generate a list of permutations, you managed to find
perhaps the least efficient algorithm possible.

This is especially ironic when you think back to your first question,
which was how to generate the combinations most efficiently.


-- 
Steven.




More information about the Python-list mailing list