The stupid question is the question not asked | |
PerlMonks |
Re: Fisher-Yates theory... does this prove that it is invalid?by adrianh (Chancellor) |
on Jul 25, 2003 at 01:58 UTC ( [id://277773]=note: print w/replies, xml ) | Need Help?? |
Please analyze the code carefully, pull out your school books, and see if I have made a mistake. Yes you have. You're not emulating a Fisher-Yates shuffle :-) Consider the original code from perlfaq:
Note how $i is decremented on each iteration. Consider how that alters the sequence of possible indices. Once you take that into account you get the textbook behaviour.
In Section
Meditations
|
|