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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to