Re: A86: Re: Creating distinct random-integer lists using ASM or BASIC
[Prev][Next][Index][Thread]
Re: A86: Re: Creating distinct random-integer lists using ASM or BASIC
people sure do like to make things hard.
I don't know if anyone else has this same answer, but here's the way I
would do it (I don't own an 86, so I'm basing this on 92):
a="01020304050607080910" total range string
b=2 string splits by 2 for each #
shuffle(a,b):func
local c,d,e,f
dim(a)/b->c number of numbers
{}->d 0 list to store random numbers
1->e 0 location in list to store
lbl over 0
rand(c)*2-1->f
expr(mid(a,f,b))->d[e] 1
left(a,f-1)&right(a,2*c-f+1)->a 0
e+1->e 0
c-1->c 0
if c=/1:goto over 0
expr(a)->d[e] 0
return d 0
endfunc
You could also do a little rearrangement. For example, if you made 'a'
equal a list of cards ("a1a2a3a411121314...q1q2q3q4k1k2k3k4") and kept
b=2 then you could shuffle cards. If you take out lines postlabeled 0
and placed "return mid(a,f,b)&left(a,f-1)&right(a,2*c-f+1)" at postlabel
1, then you could have a 1 card shuffle. It returns the full string
that was given to the program except that a random "card" from within
the "stack" has been placed at the front of the "stack." Using
"left(a,2)" you get the "card."
-Rob
>In basic you can use rand to get a number between one and 10, scan
>through
>the list and if your integer is there already, rerandomize the int >and
scan
>again.
|>
|>I'll try to be as clear as possible on this.
|>
|>Is there anyway somebody can create a list of random integers with an
inputted
|>range?....sort of like putting the integers within the range in random
order.
|>
|>For example, if you input 1 and 10. It should generate a 10 item list
of
|>numbers from 1 to 10 that are randomly placed something like: {5, 3,
8, 9,
2,
|>1, 7, 6, 4, 10}.
|>
|>If someone knows of any optimal way of programming this either in
basic or
|>asm, preferably in asm then I'd greatly appreciate it. this will come
in
use
|>when taking statistics courses since sometimes you have the assign the
|>experimental units random numbers in order to invalidate the lurking
variable
|>of nonrandom assigning.
|>
|>Reply to this list.
|>
|>
|>Thanks,
|>
|>Mohsan H.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com