[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Shufflebug



On Tue, Jul 18, 2000 at 03:08:26PM -0500, Omer Shenker wrote:
> 
> @cards = 0 .. 51;
> 
> foreach $player (0 .. 3) {
>     for (0 .. 12) {
>         push @{$hands[$player]}, splice @cards, rand @cards, 1;
>    }
> }
> 
> This can be generalized for an arbitrary number of players and cards, with
> the leftovers in @cards to be dealt out, put in a stack, or ignored as
> desired.


Besides suffering from the same problems as being discussed, this also
suffers from being quadratic in the number of cards.

splice() is devillish when it comes to efficiency.


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe