I wrote a little script in Perl to shuffle Arrays or strings:
1 2 3 4 5 6 7 8 9 10 11 12 |
sub myshuffle { my @str = ($#_ == 0)?split(//o, $_[0]):@_; my $r1 = 0; my $r2 = 0; for(0..($#str*2)){ $r1 = int(rand($#str+1)); $r2 = int(rand($#str+1))while($r1 == $r2 && $#str>4); ($str[$r1],$str[$r2]) = ($str[$r2],$str[$r1]); } return join '', @str; } |
This are my examples:
1 2 3 4 |
print myshuffle("abcdefghijklmonopqrs").$/; print myshuffle(1,2,3,4).$/; print myshuffle(1,2,3).$/; print myshuffle(1,2).$/; |
and we got his as result:
1 2 3 4 |
obrdekohnlicgsfqapjm 2431 231 21 |
Very good information. Lucky me I found your internet site by chance (stumbleupon).
I actually have book-marked it for later!