Let me preface this by saying you should ignore everything I write, I'm anal
My take...
Place all 52 cards in the array, generate say 100 tuples of two numbers less then 52.
Then for every tuple generated switch the elements in the array that correspond to the first and last value in each tuple. This will randmomize the array in place.
Then just feed the first however many elements are asked for from the array.
I like this because it avoids collision in the randomizer. If a collision occurs it's no biggy, you don't recompute, if you collide in the other scheme you have to recompute another random number with the possibility of colliding occuring again.
With 51 cards generated you can imagine how the number of collisions will grow. The other scheme works with 52 cards because the number is small.
But what if we were shuffling magic cards? Every single magic card ever made would be in the 1,000s granted you would never deal that many cards, but can see how this could be a problem.
__________________
"It better be funny"
|