Re: TIB: 83+ problem


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

Re: TIB: 83+ problem




Okay, here goes: (not quite in perfect sytax, you can make the necessary
corrections yourself)   (key: =/ is "not equal to", -> is "store")
Note: this program will match pairs so that students from one half of the
group will be matched with students from the other half (ex. say N=10,
student 4 will have a partner from no.'s 6-10, ie 7 is a possible partner but
2 is not).  This is slightly less random, but easier to program. If you need
a truely random prog, let me know.

{0} -> L1
{0} -> L2
Lbl 0
Input "Students?", N
If N/2 =/ iPart(N/2)       ; checks for even # of students
Goto 0
For(X, 1, N/2)              ; loops once for each pair of students
Lbl 1
RandInt(1,N/2) -> A      ; gets random number
1 -> Z
Repeat Z=dim(L1) or A=L1(Z)      ; checks to see if # is repeat
Z+1 -> Z
End
If Z =/ dim(L1)          ; if yes, get new #
Goto 1
A -> L1(X)               ; store in list
Lbl 2                                        ; same as above, except other
half
RandInt(N/2+1,N) -> A
1 -> Z
Repeat Z=dim(L2) or A=L1(Z)
Z+1 -> Z
End
If Z =/ dim(L2)
Goto 1
A -> L2(X)
End                                      ; end loop
For(X,1,N/2)
Pause {L1(X), L2(X)}         ; display sets of partners
End

That should do the trick.

Eric Tollefson
CmdrER01@yahoo.com


Rob Smith wrote:

> i am helping a teacher i know and he has asked me to write a program that
> takes the number of students and randomly pairs them together. i have no
> clue how to so this on a 83+ calc, so i am writing this to you. How would
> you guys do this?
> Thanks,
> Rob Smith
> ----
> Stupidity got us into this mess - why can't it get us out?
> Proud member of:
>     * <http://pa.ticalc.org>Programmers Anonymous
>     * <http://www.tigalaxy.com>TIGALAXY
>     * <http://c489.tigalaxy.com>C489
>     * <aim:addbuddy?screenname=Billvortex>Add Me To Your AIM Buddy List


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com



References: