Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
All,
I need to derange the values of an array randomly (for some definition of random). I could use tye's very nice Derangements iterator and call it a random number of times, but that seems wasteful. I could also use List::Util's shuffle() and continue to swap and elements that remain in their original positions until all are swapped - but that's seems clumsy. Anyone have a good algorithm for generating a random derangement? Cheers - L~R In reply to Random Derangement Of An Array by Limbic~Region
|
|