I'm not sure how well this will run, but my first instinct is to do a
recursive permutation.
Basically, you write it so that the function returns a list of
permutations permute(list, length) such that
permute("1,2,3,4,5,6,7", 6)
returns a list of each of those numbers plus the permute of the
remaining list, and length l-1.
That is,
permute("1,2,3", 2)= 1 + permute("2,3", 1) and 2 + permute("1,3", 1) and
3 + permute("1,2", 1)
Make sense?
--Ben Doom
Ken Fassman wrote:
> Hi,
> I have a problem I'm struggling to solve in ColdFusion - I wonder if someone
> can help me with.
>
> I am being given a variable length, numeric string (min 6, max 20). I need
> to show all combinations of those values that will result in a unique set of
> 6. The resulting output is sorted - so 1,2,3,4,5,6 is the same as
> 1,2,3,4,6,5.
>
> I'd also like to see if there is an easy way to calculate the expected
> number of each in advance.
>
> Just to illustrate what I'm looking to do (in case its not clear from
> above):
>
> The input string might be "1,2,3,4,5,6,7" and I'd need to return the
> following results:
> 123456
> 123457
> 123467
> 123567
> 124567
> 134567
> 234567
>
>
> Any thoughts on this on how to approach this are greatly appreciated.
>
> Thanks!
>
> - KsF
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Enterprise web applications, build robust, secure
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289419
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4