• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best way to get a non-repeating random number?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Best way to get a non-repeating random number?
      • From: WT <email@hidden>
  • Prev by Date: Re: Reading in dictionary from txt file: options for speed
  • Next by Date: Re: Best way to get a non-repeating random number?
  • Previous by thread: Re: Best way to get a non-repeating random number?
  • Next by thread: Re: Best way to get a non-repeating random number?
  • Index(es):
    • Date
    • Thread