Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Random Derangement Of An Array

by Corion (Pope)
on Jul 05, 2008 at 21:44 UTC ( #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
Node Status?
node history
Node Type: note [id://695751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2021-04-13 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?