12-07-2009 09:05 PM
Hello,
I am trying to generate multiple random numbers between a given set of numbers (1-52) and not have the same number generated twice within that set. I can compare the last and next numbers with the compare function but how would I go about comparing all of the generated numbers without using a huge list of shift registers...
Any help/ideas are welcome and appreciated.
Jason
Solved! Go to Solution.
12-07-2009 09:13 PM
12-07-2009 09:18 PM
Thank You, I was unclear. I can generate the numbers within the set I need. My problem was that I didnt want the same number ever generated again within that set. One idea I had was to build an array each time a random number is generated using the same shift register to pass the number each time and then search the array with the new number. Im going to write that and see if that fixes my problem.
Regards,
jason
12-07-2009 09:36 PM
Solved my own problem. Im passing the random number through a shift register each case and building an array each time. I then search the array for the new random number. If the number is not found I get a value of -1, anything else is an index value of 0-whatever. So a greater than (-1) comparer will indicate that the same number is within the array and I can then re-run that case until the same number is not found.
Regards,
Jason
12-07-2009 10:13 PM
You can use mathscript for a very straightfoward approach
12-07-2009 10:47 PM
Here is an implementation of Jason's solution.
steve