### Math problem giving me a headache, please advise!

Hello math folks

I need your help to help me solve a math trick, any advice is very appreciated

I have these numbers: 4 3 2 1.5 1 0.75 0.5 0.25

I need to create a coll that contains ALL the permutations of these numbers which the sum is always equal to 4

any idea for a quick patch or suggestion?

many thanks

For permutations I mean

4

3 1

1 3

2 2

2 1 1

1 2 1

1 1 2

1 1 1 1

0.5 1 1 1

1 0.5 1 1

1 1 0.5 1

1 1 1 0.5

and so on…

You used the word "permutation," but the example you gave is not a collection of permutations. A permutation is a reordering, so if your original sequence contains 8 elements, as yours does, every permutation will also contain 8 elements.

So I haven’t a clue about what problem you’re trying to solve. Before anyone can help you, you’ll have to explain the problem accurately and completely.

you’re right, I’ll try to explain better.

I need to create a coll that contains all the possible lists (from 1 to 16 numbers) using (4 3 2 1.5 1 0.75 0.5 0.25)

in which total sum is 4

for example:

4

—

2 2

—

2 1 1

1 2 1

1 1 2

–

1.5 1 1.5

1 1.5 1.5

1.5 1.5 1.5

—

0.5 0.5 1 2

2 1 0.5 0.5

0.5 1 0.5 2

2 1 0.5 0.5

0.5 2 0.5 1

and so on

as you can see as the list grows I need also all the permutations

sorry for my english, not easy to talk of math in a foreign language

1.5 1 1.5

1 1.5 1.5

1.5 1.5 1

SORRY

I would concentrate my efforts on 2 individual problems:

1- Getting the different combinations of numbers, independently of the order of the elements in the list.

To that extent, you could use a high to low generation methodology. Here’s an example to get to the number "3":

3

2 1

2 0.75 0.25

2 0.5 0.5

2 0.5 0.25 0.25

2 0.25 0.25 0.25 0.25

1.5 1.5

1.5 1 0.5

1.5 1 0.25 0.25

1.5 0.75 0.75

1.5 0.75 0.5 0.25

1.5 0.75 0.25 0.25 0.25

1.5 0.5 0.5 0.5

1.5 0.5 0.5 0.25 0.25

…….

2- Generate all possible permutations for each list created, maybe with the help of the [permute] object from http://www.essl.at/works/rtc.html

Disclaimer: I’ve never tried any of this… ;-)

Hi Pedro

yes that’s what I’m doing.. I just hoped there was a faster method..

For permutations I’m using zl.permute

it is coming like this

4

3 1

3 0.75 0.25

3 0.5 0.5

3 0.5 0.25 0.25

3 0.25 0.25 0.25 0.25

2 2

2 1 1

2 1 0.75 0.25

2 1 0.5 0.5

2 1 0.5 0.25 0.25

2 1 0.25 0.25 0.25 0.25

2 1.5 0.5

2 1.5 0.25 0.25

2 0.75 0.25 0.75 0.25

2 0.5 0.5 0.5 0.5

2 0.5 0.25 0.25 0.5 0.25 0.25

2 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25

1.5 1.5 1 0.75 0.25

1.5 1.5 0.5 0.5

1.5 1.5 0.5 0.25 0.25

1.5 1.5 0.25 0.25 0.25 0.25

and so on…

sorry zl.scramble

Great patch, nicolas! Simple and efficient.