Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14348 > unrolled thread
| Started by | eros olmi <erosolmiz@hotmail.com> |
|---|---|
| First post | 2013-04-28 04:58 +0000 |
| Last post | 2013-05-06 06:25 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
combinations problem eros olmi <erosolmiz@hotmail.com> - 2013-04-28 04:58 +0000
Re: combinations problem totarefugium <mtaktikos@t-online.de> - 2013-05-06 06:25 +0000
| From | eros olmi <erosolmiz@hotmail.com> |
|---|---|
| Date | 2013-04-28 04:58 +0000 |
| Subject | combinations problem |
| Message-ID | <klia8o$s8q$1@smc.vnet.net> |
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&]
[toc] | [next] | [standalone]
| From | totarefugium <mtaktikos@t-online.de> |
|---|---|
| Date | 2013-05-06 06:25 +0000 |
| Message-ID | <km7ick$ica$1@smc.vnet.net> |
| In reply to | #14348 |
On 28.04.2013 06:58, eros olmi 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&]
Hi, the following should work about 68 times faster:
Select[Map[Union, IntegerPartitions[152, {6}, Range[49]]],
Length[#] == 6 & ]
cheers,
Michael Taktikos
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web