----------------------------------- Azzy Mon Nov 03, 2003 6:20 pm Rand.Int ----------------------------------- how can you make it so it can only use one number one time? ----------------------------------- Mazer Mon Nov 03, 2003 6:41 pm ----------------------------------- could you explain what you mean? ----------------------------------- poly Mon Nov 03, 2003 6:46 pm ----------------------------------- I think he means, have say a randint randomizing from 1 to 6 and only having 1 show up once, 2 show up once etc. ----------------------------------- Azzy Mon Nov 03, 2003 6:50 pm ----------------------------------- exactly like poly said.like for the one i'm doing i have 52 but each one can only show up once.so there can only be 1 of the 35 variable in the array. ----------------------------------- poly Mon Nov 03, 2003 6:54 pm ----------------------------------- ok so have the randint and have an array keeping track of the numbers and have either an array or variable making sure no numbers are the same. I understand what you mean and how to do it, just I am shitty at explaining things just like above! ----------------------------------- Tony Mon Nov 03, 2003 8:10 pm ----------------------------------- What you should do is to have an array 1 to w/e largest number you want. Then you use Rand.Int to randombly pick an index of the number. It will be your first result. Then take that array element out and shift the array so that there're no gaps. So each time, you pick a random number from 1 to n-try. ----------------------------------- nis Thu Nov 06, 2003 6:56 pm ----------------------------------- Like tony said create an array but create an array 1 to the highest num of boolean and put the randint inside a loop when a random number is choosen go to the array of that number and set it to true. and then exit the loop. If the array is allready true then have it pick another number var Array : array 1 .. 6 of boolean init(false,false,false,false,false,false) var num : int loop randint(num,1,6) if not (Array(num)) then Array(num) = true exit end if end loop %Then do what ever you have to do ----------------------------------- Tony Thu Nov 06, 2003 8:02 pm ----------------------------------- bad nis :roll: tsk tsk tsk :lol: you got it all wrong. You suppost to generate a number number just once, not untill you pick one that wasn't used. What if it's a 1000 numbers to be generated? You'll have a 1/1000 chance of getting that last number and it will take you a LONG while. here's my code: var randN:int %just to hold the number var numbers:array 1..10 of int for i:1..10 numbers(i):=i end for for decreasing i:10..1 randN := Rand.Int(1,i) put numbers(randN) if randN not=i then for a:randN+1..i numbers(a-1):=numbers(a) end for end if end for ----------------------------------- nis Fri Nov 07, 2003 12:00 am ----------------------------------- damn That is good code :twisted: *cough* Watch your back *cough* :roll: Showing me up like that :cry: ----------------------------------- Tony Fri Nov 07, 2003 10:12 am ----------------------------------- heh :lol: sorry nis ----------------------------------- Azzy Fri Nov 07, 2003 9:10 pm ----------------------------------- There was a problem with the code.That is for an int array but I need that code for a string array.Is there any way you can change that? ----------------------------------- Tony Fri Nov 07, 2003 9:28 pm ----------------------------------- :? You asked for numbers. use one number one time ether way. You get a list of numbers - use them as your array indexes to pick stings out.