in reply to How to generate distinct random numbers?
sub distinct_random_int { my ($num, $start, $end) = @_; my @rand; my @avail = $start..$end; push @rand, splice(@avail, rand(@avail), 1) for 1..$num; @rand; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to generate distinct random numbers?
by Aristotle (Chancellor) on Sep 06, 2004 at 23:31 UTC | |
by ysth (Canon) on Sep 07, 2004 at 06:05 UTC |