Re: Best way to get a non-repeating random number?
Re: Best way to get a non-repeating random number?
- Subject: Re: Best way to get a non-repeating random number?
- From: Graham Wheel <email@hidden>
- Date: Tue, 14 Apr 2009 14:45:11 -0700
Focusing just on the non-repeating aspect, Deitel & Deitel discuss an
algorithm to achieve this in C How To Program. Lets assume we are
talking about shuffling a deck of 52 cards. Assign each card to an
array element, then iterate completely through the array, swapping
each element with a randomly chosen element. The result will be a
shuffled deck, and each card in the resulting deck will be unique.
This does not address of course the issue of the quality of the random
number generator.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden