A86: Re: Creating distinct random-integer lists using ASM or BASIC


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

A86: Re: Creating distinct random-integer lists using ASM or BASIC





On Sat, 03 Oct 1998 07:47:49 PDT "In FuZeD" <zone_ti@hotmail.com> writes:
>
>
>>no!  you fill a list with all the numbers in the range and shuffle!
>>say you want 1-10, you fill the list with
>>{1 2 3 4 5 6 7 8 9 10}
>>then you pick two places at random, say 3 and 8, and swap them
>>{1 2 8 4 5 6 7 3 9 10}
>>then you repeat this several times.
>>
>>
>>-josh
>
>This would actually be slower. Not to mention is you say shuffled it 
>10 
>times with random places some #'s would stay in their original spot. 
>The 
>routine I posted is faster and is better with randomizing. U people 
>can 
>stop posting now. He has his routine.

how would this be slower?  you don't ever have to compare numbers, let
alone the whole list.  yeah, some of the numbers would stay in the
original place, but with you method, some would end up there anyway.  if
you don't swap enough times, it will be pretty bad randomness, so if 10
times isn't good enough, try 20.  yeah,yeah he's got a routine he's happy
with, but there's still the principle!

yeesh!  with your method, when you get to the second to last number
(let's stay with 10 numbers for the sake of argument), you have to
compare to 8 other numbers, and 8 times out of 10, you have to pick
another number and try again.  and my method is slow?

-josh

>
>-InFuZeD " The Basic Guru "
>
>p.s.: Anyone needing Basic help can email me personally at 
>zone_ti@hotmail.com
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com
>

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


References: