🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.theory
Article #1932

Re: Looking for random permutation generation algorithms

#1932
From: Larry Loen
Date: Sat, 09 Jan 1993 22:09
29 lines
2022 bytes
If I understand the request correctly, the original poster is looking
for a way of generating a pseudo random string of digits including all
number 0, 1. . . n-1 for n numbers, without repeating any.

The simplest way to do this comes from APL.  What you do is generate
a string of n numbers using any suitable random number generator.

Then, you do a "sort" of the numbers using the "index array" method.

That is, you leave the original numbers in place, and sort an array
of "indexes" to the original data.

As it happens, that sorted array will, itself, provide the array
required.  In other words, the original random numbers (that may have
had repeats) is discarded after the sort, because they were merely means
to an end.

Now, if that doesn't quite "cut" what is looked for, here, such an array
can probably be used to manipulate some sort of starting permutation
in a pseudo-random way with only a little more thought.  However, since
the numbers don't repeat, it would seem to form a permutation-substitution
by simply having index i replaced by index i+1 and so forth.

If one has a built-in sort handy, it is very easy to do.

-- 
   Larry W. Loen        |  My Opinions are decidedly my own, so please
                        |  do not attribute them to my employer
Technical Details
Message-ID: <1993Jan09.220921.19430@rchland.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!linus!philabs!acheron!scifi!watson!yktnews!admin!wo0z!lwloen
References: <1993Jan6.014749.15323@ee.ubc.ca> <1993Jan6.224804.6116@dsuvax.dsu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.theory,sci.crypt,sci.math,rec.puzzles
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!linus!philabs!acheron!scifi!watson!yktnews!admin!wo0z!lwloen
From: lwloen@rchland.vnet.ibm.com (Larry Loen)
Subject: Re: Looking for random permutation generation algorithms
Sender: news@rchland.ibm.com
Message-ID: <1993Jan09.220921.19430@rchland.ibm.com>
Date: Sat, 09 Jan 1993 22:09:21 GMT
Reply-To: lwloen@rchland.vnet.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
References: <1993Jan6.014749.15323@ee.ubc.ca> <1993Jan6.224804.6116@dsuvax.dsu.edu>
Nntp-Posting-Host: wo0z.rchland.ibm.com
Organization: IBM Rochester
Lines: 29