Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Random Derangement Of An Array

by pc88mxer (Vicar)
on Jul 05, 2008 at 21:44 UTC ( #695752=note: print w/replies, xml ) Need Help??


in reply to Random Derangement Of An Array

Have a look at this thread: random derangement. Suggestions include:
  1. generating a random permutation until you get a derangement (expected number of tries is e), and:
  2. using a modification of the basic random shuffle algorithm
It's a Mma mailing list, but I'm sure the algorithms can be translated to perl.

Update: the modification of the basic random shuffle algorithm is to swap position j with a random element from positions j through the end which doesn't violate the derangement condition.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://695752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2021-03-03 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (77 votes). Check out past polls.

    Notices?