Re: TIB: Random Number Generation Different From The One Before


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

Re: TIB: Random Number Generation Different From The One Before





This is the only way I know to do it.  Yes the only way that you can
do this is by testing to see if you have already used the number.

this should do the trick:
:0->c                         sets a counter at 0
:lbl Start
:seq(0,x,1,24)->L             creates a list to store all the used
values for N
:1+mod(int(24*rand),24)->N    Creates the random value for N, 1<=N<=24
:for y,1,24                   For loop to check if N has been used
before
:if L(y)==N:goto Start         "
:end                           "
:c+1->c:N->L(c)               If the program gets here, you haven't
ever used N before.  Counter increases by one, then N is stored in the
list at the L(c) position.

you can then be assured that N has never been used before.

---Jeanne9005@aol.com wrote:
>
> 
> On the 86, how do I get a random integer between 1 and 24, and then
if the
> number has already been used, it can't be used again?  Is there any
shorter
> way than testing all the numbers prior to it for the chosen number? 
Please
> don't waste mine and your time by telling me you don't have an 86. 
Thanks in
> advance.
> 
> Glen
> 
> 

==

The Garth Johnson

Visit my website!  http://www.bigfoot.com/~garthjohnson
                "Now with jokes for your mental enjoyment!"
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com