On Tue 18 July 2000 2:36 PM Bernie Cosell wrote: > Not quite: for bridge, you only have to randomize the position *mod*4 > -- this is actually a lesser constraint than having to have a shuffle > that can generate all 52! [or whatever it is] shuffles with equal > probability. That is, you don't care that card A's *position* is > indpendent of its position in the pre-shuffled deck, but rather that > *the*hand*that*gets*it* is independent of that... alas, I can't > offhand come up with an algorithm that I can defend that just makes a > "random deal" [rather than a randomly shuffled deck] but my intution > says we ought to be able to come up with one... > > /Bernie\ > > -- > Bernie Cosell Fantasy Farm Fibers > mailto:bernie@fantasyfarm.com Pearisburg, VA > --> Too many people, too few sheep <-- @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. -- Omer Shenker oshenker@iname.com ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe