in reply to biased random number picking
Here is a solution using just an array slice:
use v5.14; use strict; use warnings; my @options = (1 .. 100); for (1 .. 100) { my $choice = int(rand($#options + 1)); say 'Choice #', $_, ' is ', $options[$choice]; @options = @options[ 0 .. ($choice - 1), ($choice + 1) .. $#option +s ]; }
HTH,
Athanasius <°(((>< contra mundum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: biased random number picking
by salva (Canon) on Jul 12, 2012 at 05:32 UTC |