MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: generating submultisets with repeated elements


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 %^>



  • Prev by Date: Re: How to find which variable caused the trigger in Manipulate[]
  • Next by Date: Re: Re: confused about == vs === in this equality
  • Previous by thread: Re: Re: generating submultisets with repeated elements
  • Next by thread: Re: Re: generating submultisets with repeated