Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: combinations problem
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Ray Koopman

Posts: 3,383
Registered: 12/7/04
Re: combinations problem
Posted: Apr 28, 2013 5:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@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&]





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.