Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45872

Re: Simple algorithm question - how to reorder a sequence economically

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.158
X-Spam-Level *
X-Spam-Evidence '*H*': 0.69; '*S*': 0.00; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '24,': 0.16; 'index': 0.16; 'wrote:': 0.18; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'produces': 0.31; 'provided,': 0.31; 'fri,': 0.33; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'library.': 0.36; 'sequence': 0.36; 'subject:Simple': 0.36; 'should': 0.36; 'list': 0.37; 'received:209': 0.37; 'easiest': 0.38; 'pm,': 0.38; 'most': 0.60; 'tell': 0.60; 'more': 0.64; 'different': 0.65; 'taking': 0.65; 'to:addr:gmail.com': 0.65; 'obvious': 0.74; 'idiot': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=nnF79MDWBeC62YsMvD4rd/BJo1MfSVpPOzkfR6UUXtc=; b=sddVTWe3MZtd9JK2X0OydtxXE+HC5mP+iR1gER3XFb4jkFUjB+HUL9gIAB3vcgA6zx zQz1OLJX7UPVZ4kOaV3PGttNBzRHGzIYPeotgidtuEcjfrkeG6B4HOPv/lQ1JSdSuwyp RUpO81b40wjBfqP8yMmOvjfDkqBfJFdt+Z0zAyzowdPsAVQwVnIH/VXdP4yHBHQVAFo1 qEOvpMIamHh+2uKMkCNGrS+Fd7ROY8ZuJok57VcImrL3kfKJy3jzSLQunn00Ng/GnSLY 4E4m+GUqZIQ4lj8qlDDKqUhZ2bvD3Byckwjkq15ib+X6sCaWXMJ+JUd+OSv83J14LIJl Yf5Q==
MIME-Version 1.0
X-Received by 10.229.175.137 with SMTP id ba9mr1498923qcb.43.1369385228030; Fri, 24 May 2013 01:47:08 -0700 (PDT)
In-Reply-To <CAPTjJmqmWBACxzrFQzVzRDOvft47S7dbeAedFbPTyiahyjpEVQ@mail.gmail.com>
References <a31c773f-88d8-4489-8640-12123d884e4d@m2g2000vbb.googlegroups.com> <CAPTjJmqmWBACxzrFQzVzRDOvft47S7dbeAedFbPTyiahyjpEVQ@mail.gmail.com>
Date Fri, 24 May 2013 09:47:07 +0100
Subject Re: Simple algorithm question - how to reorder a sequence economically
From Fábio Santos <fabiosantosart@gmail.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=001a11c2dec413f89c04dd72d831
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2052.1369385236.3114.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369385236 news.xs4all.nl 15938 [2001:888:2000:d::a6]:54008
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45872

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 24 May 2013 09:41, "Chris Angelico" <rosuav@gmail.com> wrote:
>
> On Fri, May 24, 2013 at 6:14 PM, Peter Brooks
> <peter.h.m.brooks@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Simple algorithm question - how to reorder a sequence economically Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-24 01:14 -0700
  Re: Simple algorithm question - how to reorder a sequence economically Chris Angelico <rosuav@gmail.com> - 2013-05-24 18:37 +1000
  Re: Simple algorithm question - how to reorder a sequence economically Fábio Santos <fabiosantosart@gmail.com> - 2013-05-24 09:47 +0100
  Re: Simple algorithm question - how to reorder a sequence economically Chris Angelico <rosuav@gmail.com> - 2013-05-24 19:11 +1000
    Re: Simple algorithm question - how to reorder a sequence economically duncan smith <buzzard@invalid.invalid> - 2013-05-24 15:33 +0100
  Re: Simple algorithm question - how to reorder a sequence economically Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-24 06:10 -0400
  Re: Simple algorithm question - how to reorder a sequence economically Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-24 10:52 +0000
    Re: Simple algorithm question - how to reorder a sequence economically Ned Batchelder <ned@nedbatchelder.com> - 2013-05-24 07:26 -0400
      Re: Simple algorithm question - how to reorder a sequence economically Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-24 06:23 -0700
        Re: Simple algorithm question - how to reorder a sequence economically Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-24 13:57 +0000
        Re: Simple algorithm question - how to reorder a sequence economically Robert Kern <robert.kern@gmail.com> - 2013-06-12 14:14 +0100
    Re: Simple algorithm question - how to reorder a sequence economically John Ladasky <john_ladasky@sbcglobal.net> - 2013-05-24 10:33 -0700
      Re: Simple algorithm question - how to reorder a sequence economically John Ladasky <john_ladasky@sbcglobal.net> - 2013-05-25 18:25 -0700
        Re: Simple algorithm question - how to reorder a sequence economically Roy Smith <roy@panix.com> - 2013-05-25 21:49 -0400
  RE: Simple algorithm question - how to reorder a sequence economically Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 18:00 +0300
    Re: Simple algorithm question - how to reorder a sequence economically Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-24 12:01 -0700
      RE: Simple algorithm question - how to reorder a sequence economically Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 00:33 +0300
        Re: Simple algorithm question - how to reorder a sequence economically Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-24 17:28 -0700

csiph-web