my %remap; my @result; while ($K--) { my $x= int rand $N--; push @result, $remap{$x} // $x; $remap{$x}= $N; }
In reply to Re^2: Pick k numbers at random
by NERDVANA
in thread Pick k numbers at random
by Chuma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |