I use this method.  Originally I used this to shuffle a deck of cards.

<cfset ca = arrayNew(1) />
<cfloop from="1" to="20" index="i">
   <cfset ca[i] = i />
</cfloop>
<cfset i=1 />
<cfloop from="1" to="20" index="i">
  <cfset ranDom = RandRange(1,arrayLen(ca)) />
  <cfoutput>#ca[ranDom]#<br /></cfoutput>
  <cfset arrayDeleteAt(ca,ranDom) />
</cfloop>


Paul.

On Sun, Dec 14, 2008 at 6:45 PM, Don L <[email protected]> wrote:

> Man, I'm not having a good time with a seemingly simple problem, that is,
> to generte a bunch of (say, 6) of unique numbers out of a range.  Say, the
> range is 20.
> My current code technique is mainly to use a 'pool of numbers, each less
> than 20', if found, try generate a number again (and here's the potential
> problem, that is, you don't know if the newly generated number would be a
> member of 'pool of numbers', so, one would have to run a check again...  So,
> for now, the code sometime produce one or even two duplication numbers.  Do
> you have a better way?
>
> Thanks.
>
> Don
> Chunshen Li
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316748
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to