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 12:47:00 -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 (56)
if randomNumberList does not contain thisRandomNumber then
set the end of randomNumberList to thisRandomNumber
end if
end repeat
--
Paul Skinner