Subtraction of list items

Hello everyone,

As a Dynamo and Python beginner, I have a question.
I want to subtract every value in a list with every value in the same list, but not with itself.
For example, the list consists of:
15
12
18
implemented this means:
15-12
15-18
12-18.

However, the whole thing should be implemented in such a way that it also works with other list lengths.

Thanks for your help!

Hi @superfabi.krause,

this is quite a good coding challenge, but I am missing some restrictions.

Should you filter by Unique answer or unique equations (which can still give the same answer )?

you can do:
15-12 (as suggested), but also 12-15 = -3, this is a unique equation.

should the awnser always be positive? if not, you have more combi’s?

1 Like

:roll_eyes:

1 Like

This is the one you are exampling

this is when you always want the bigger value first

2 Likes

Hmm, @superfabi.krause mentions that you should not apply the function on the same value

say:
15-15

Which happens if you use cross-product. Also, now the same equation happens more then ones?

1 Like

after that we can simply remove the 0…it will be easy I think…but I don’t know an exact expectation of @superfabi.krause

1 Like

Thank you for your help! I think it works.

I’ll try that too! Thanks

@superfabi.krause Another way using List.Permutations: Subtract.dyn (18.3 KB)

3 Likes