[A83] Re: shuffle code help please


[Prev][Next][Index][Thread]

[A83] Re: shuffle code help please



hmm i'll have to try that.. r

In a message dated 9/18/2002 6:42:48 AM Pacific Daylight Time, 
joe@joepnet.com writes:


> I read some stuff on this a while ago, and found that one of the most
> elegant methods of shuffling a deck of cards was this:
> You start with a variable equal to 52, and get a random number from it
> 
(0-51).  You take the card with this number, move the cards on top of it
> 
> back one, move it to the top of the deck, decrement the variable to 51, and
> do it over.  So the next time you get a random number from 0-50, take that
> card out, move the cards on top of it back one spot, move it to the top of
> the deck and repeat.  You quit when you decrement your variable and it is
> zero =)
> This algorithm is guaranteed to be random.
> - - Joe
> joe@joepnet.com
>