Simple algorithm question - how to reorder a sequence economically

Fábio Santos fabiosantosart at gmail.com
Fri May 24 04:47:07 EDT 2013


On 24 May 2013 09:41, "Chris Angelico" <rosuav at gmail.com> wrote:
>
> On Fri, May 24, 2013 at 6:14 PM, Peter Brooks
> <peter.h.m.brooks at gmail.com> wrote:
> > What is the easiest way to reorder a sequence pseudo-randomly?
> >
> > That is, for a sequence 1,2,3,4 to produce an arbitrary ordering (eg
> > 2,1,4,3) that is different each time.
> >
...
> It works, it produces a unique list for any given index provided, but
> it's not the cleanest or most efficient. But I know someone'll improve
> on it... or tell me I'm an idiot for not taking a more obvious
> approach :)
>
> ChrisA

I think that is pretty much itertools.permutations from the standard
library. The OP should check it out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130524/40d451ba/attachment.html>


More information about the Python-list mailing list