Re: Random number generator without duplicates?
Re: Random number generator without duplicates?
- Subject: Re: Random number generator without duplicates?
- From: Paul Skinner <email@hidden>
- Date: Tue, 17 Apr 2001 16:57:01 -0400
on 4/17/01 9:54 AM, email@hidden wrote:
>
How can I get a list of random numbers that does not include any duplicates?
>
I would want to use these parameters: six random numbers from 1 to 56, as a
>
list or as six variables, no duplicate numbers.
>
>
Thanks in advance,
>
Garry Simon
I would generate a random number , use contains to determine if the list
already contains it, and if not add it to the list. Repeat until the length
of the list is 6.
set randomNumberList to {}
repeat while (length of randomNumberList is less than 6)
set thisRandomNumber to random number from 1 to 56
if randomNumberList does not contain thisRandomNumber then
set the end of randomNumberList to thisRandomNumber
end if
end repeat
p.s. I know that this horse has been beaten by now. This is a repost of a
message I sent this AM to test if my posts will show up if I send them
repetatively. Once doesn't seem to do it today.
--
Paul Skinner