# Re: Programming Challenge

I'm not real good with Ti-BASIC but in BASIC You can do it like this....

DIM Cards(52)
FOR I = 1 to 52 : Cards(I)=I : next
FOR I = 1 to 100
j=int(rnd()*52+1)
k=int(rnd()*52+1)
t=cards(j)
cards(j)=cards(k)
cards(k)=t
next i

Now cards(*) has the numbers 1 thu 52 in ramdomized...
use cards(x) mod 13 to get the card
use cards(x) div 13 to get the suit

MR-Data on the UNDERNET
-----Original Message-----
From: Steve Muckle <muckle@RLC.NET>
To: CALC-TI@LISTS.PPP.TI.COM <CALC-TI@LISTS.PPP.TI.COM>
Date: Wednesday, April 22, 1998 15:02
Subject: Programming Challenge

Dear List,
I am trying to make a program that will simulate a deck of cards for a collectable card game.  I would rather lay out a set of numbers at the beginning (each number representing a particular card) than pick them on the fly.  What my problem is is that I need to get a list (or a matrix, it doesn't matter) of numbers 1 through 60, randomly assorted, BUT no number appearing more than once.  It may sound easy, but it is fairly difficult (at least I didn't see an easy way to do it.)  It also has to be relatively quick.  I could have the program check every random number it gets to see it if is already in the list, but that would be impractical in terms of speed and program size.
Things would be a lot simpler if you could delete a list element from a list while in a program, but I didn't find a way to do that in my calculator manual (I'm using a TI-86, by the way). The only way to delete a list element is to go into the "List Editor" and delete it manually.  If you could delete a list element, You could just remove that number from a list of 1-60 and then pick another from that list.  That way you couldn't get the same number twice.
Anyway, I know there are some savvy programmers out there that are much more acquainted with programming in basic than I am.  So, if you have any ideas, please help me out!
Thanks a lot for your time,
steve muckle