Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: combinations problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130652] Re: combinations problem
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 28 Apr 2013 05:18:35 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Timing@Length@Select[Subsets[Range[49],{6}],Total[#]==152&]

{211.15, 165490}

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

{1.86, 165490}

On Sat, Apr 27, 2013 @ 09:58 PM, eros olmi <erosolmiz at hotmail.com> wrote:
> Hi
> i want to select 6 combinations from numbers 1 to 49 with condition that its sum equal 152, the following code works but its timing is 157 seconds on windows xp mathematica v 8. can we make this timing shorter ?
> Select[Subsets[Range[49],{6}],Total[#]==152&]



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