Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Random Derangement Of An Array

by Corion (Patriarch)
on Jul 05, 2008 at 21:44 UTC ( [id://695751]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $shift = rand $#array;
    @array = map { $array[ ($_ + $shift) % @array ]} 0..$#array;
    
  2. or download this
    my $shift = rand $#array;
    
    ...
        my @middle = splice @array, $middle, 1;
        @array = @middle, map { $array[ ($_ + $shift) % @array} reverse 0.
    +.$#array;
    };
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-16 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found