Re: generating submultisets with repeated elements
- To: mathgroup at smc.vnet.net
- Subject: [mg103784] Re: [mg103681] generating submultisets with repeated elements
- From: David Bevan <david.bevan at pb.com>
- Date: Mon, 5 Oct 2009 13:58:10 -0400 (EDT)
Dan, Adriano, Kurt,
Thanks for the feedback.
Here are some performance results:
(* Dan *)
Length[multiSetsUpToK[Range[20],7]]//Timing
{18.14,888029}
(* Adriano *)
Length[coinSetsAdriano[Range[20],7]]//Timing
{9.516,888029}
(* Kurt *)
Length[coinSetsKurt[Range[20],7]]//Timing
Subsets::toomany: The number of subsets (189407486533) indicated by Subsets=
[{1,1,1,1,1,1,1,2,2,2,<<130>>},{1,7}] is too large; it must be a machine in=
teger.
And with my code:
Length[coinSets[Range[20],7]]//Timing
{5.063,888029}
My 'accumulator' approach seems to be quite effective!
However, I'm sure this can be improved significantly with the technique use=
d for KSubsets without too much difficulty.
David %^>
- Follow-Ups:
- Re: Re: generating submultisets with repeated
- From: David Bevan <david.bevan@pb.com>
- Re: Re: generating submultisets with repeated