Re: [algogeeks] shuffle

2010-06-26 Thread sharad kumar
int array[52]; for(i=0;i<52;++i) { int rand=rand()%52; swap(a[i],a[rand]); } On Sat, Jun 26, 2010 at 8:35 PM, Anil C R wrote: > I'm assuming that the random function can generate uniformly distributed > random numbers between 0 and n(excluding n), where n is an +ive integer. > > def randperm( A

Re: [algogeeks] shuffle

2010-06-26 Thread Anil C R
I'm assuming that the random function can generate uniformly distributed random numbers between 0 and n(excluding n), where n is an +ive integer. def randperm( A ): for i in range(0, n): t = i+1 + random(, n - i-1 ) swap(A[t], A[i]) note that the permutation is in-place. Anil

[algogeeks] shuffle

2010-06-26 Thread sharad kumar
Write a method to shufle the deck. The constraint is it has to be a perfect shuffle - in other words, every 52! permutations of the deck has to be equally like (given a completely random function which is theoretical of course) -- You received this message because you are subscribed to the Google