Re: FAQ 4.48 How do I shuffle an array randomly?
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Sep 2005 10:59:14 GMT
Donald King <dlking@xxxxxxxx> wrote in news:CgJZe.78026$Sj1.70599
> William James wrote:
>> PerlFAQ Server wrote:
>>> If not, you can use a Fisher-Yates shuffle.
> However, the Fisher-Yates shuffle used in the above code is O(n) and
> will merely double in runtime when the array doubles in length.
This probably does not matter when generating different starting locations
for a game, but it is important to note:
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW: