Re: Random number generator without duplicates?
Re: Random number generator without duplicates?
- Subject: Re: Random number generator without duplicates?
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 18 Apr 2001 14:42:22 -0400
- Organization: [very little]
This removes the randomly chosen number from the set of possible
choices, after which the next random selection is made from the reduced
set. Does that solve the problem?
set nbrList to {}
repeat with i from 1 to 100
set nbrList to nbrList & i
end repeat
set randomList to {}
repeat with i from 100 to 2 by -1
set j to (random number from 1 to i)
set randomList to randomList & (contents of item j of nbrList)
if j = 1 then
set nbrList to rest of nbrList
else if j = i then
set nbrList to (items 1 thru (j - 1) of nbrList)
else
set nbrList to (items 1 thru (j - 1) of nbrList) & [optn-L]
(items (j + 1) thru i of nbrList)
end if
end repeat
set randomList to randomList & item 1 of nbrList
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[4/18/01 2:41:17 PM]