[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: not enough real programmers?



I understood "perfect shuffle" to mean exactly "one card from the left,
followed by one from the right, followed by the next from the left, etc",
i.e. new[0] = old[26], new[1] = old[0], new[2] = old[27], new[3] = old[1],
etc.

Mike

Volker Hetzer wrote in message <37AEA89C.E6088226@abg1.siemens.de>...
>Everett M. Greene wrote:
>
>> > 4.  "Write a program to perform a "perfect shuffle" on an array of 52
>> > numbers."
>>
>> Anybody with a good answer to question 4 doesn't need to be interviewing
>> for a job.  There are any number of companies, academic institutions,
>> etc. who would like a definitive answer to that problem.
>If perfect means "all permutations are equally likely", then Knuth has an
answer.
>Without having read it, I'd simply use a random number generator to put
cards
>from one array into the other (modulo the remaining cards, etc.). It should
give
>a shuffle as good as the random number generator.
>
>Greetings!
>Volker
>--
>Hi! I'm a signature virus! Copy me into your signature file to help me
spread!