$ perl -le' use List::Util q/shuffle/; my $string_length = 600; my $x_count = 10; my $joined_new_string = q/-/ x $string_length; my @positions = ( shuffle 0 .. $string_length - 1 )[ 0 .. $x_count - 1 + ]; substr $joined_new_string, $_, 1, q/X/ for @positions; print $joined_new_string; ' -----------------------------X---------------------------------------- +--------------------------------------------------------------------X +--------------------------------------------------------------------- +----X----X-------X-------------------------------------X------------- +---------------------------------------------X-X--------------------- +--------------------------------------------------------------------- +------------------------------------------------------------X-------- +--------------------------------------------------------------------- +------------------------X----------------------
In reply to Re: Difficulty in randomization
by jwkrahn
in thread Difficulty in randomization
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |