• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Random number generator without duplicates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Random number generator without duplicates? (From: email@hidden)

  • Prev by Date: Re: Random number generator without duplicates?
  • Next by Date: Re: Random number generator without duplicates?
  • Previous by thread: Re: Random number generator without duplicates?
  • Next by thread: Re: Random number generator without duplicates?
  • Index(es):
    • Date
    • Thread