MathGroup Archive 2013

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

Search the Archive

Re: combinations problem


On Sunday, April 28, 2013 5:17:32 AM UTC-4, Ray Koopman wrote:

> I want to select 6 combinations from numbers 1 to 49 with condition that its sum equal 152,

> Timing@Length@Select[IntegerPartitions[152,{6},Range@49],Unequal@@#&]
>
> {1.86, 165490}
>

Hi.  Just an interesting way to confirm the number of solutions:

Timing[Coefficient[Expand[Coefficient[
     Product[k*t^n + 1, {n, 49}], k, 6]], t, 152]]

{0.079659,165490}

= = = = = = = = = =
HTH  :>)
Dana DeLouis
Mac & Mathematica 9
= = = = = = = = = =





  • Prev by Date: Farewell to a friend
  • Next by Date: Re: how to generate piecewise function from two lists
  • Previous by thread: Re: combinations problem
  • Next by thread: how to generate piecewise function from two lists