in reply to Re: Bingo Challenge
in thread Bingo Challenge
You could speed things by shuffling @words right before the two inner loops.
becomes:foreach my $i (1..$cards) { my %seen; . . . for my $x (1..4) { for my $y (1..4) { my $word; while (1) { my $index = rand(@words); $word = $words[$index]; if (!$seen{$word}) { $seen{$word}++; last; } } . . .
use Algorithm::Numerical::Shuffle qw /shuffle/; . . . foreach my $i (1..$cards) { . . . @words = shuffle @words; for my $x (1..4) { for my $y (1..4) { my $word = shift @words; . . .
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Bingo Challenge
by Matts (Deacon) on May 20, 2002 at 06:47 UTC | |
by CharlesClarkson (Curate) on May 20, 2002 at 11:16 UTC |
In Section
Seekers of Perl Wisdom