Off topic now, but if you want to shuffle a deck of cards (or anything
else), check out java.util.Collection's shuffle() method.  Operates on
a CF array (or any other java.util.List).

cheers,
barneyb

On Sun, Dec 14, 2008 at 3:55 PM, Paul Kukiel <[email protected]> wrote:
> 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:316749
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to