How to find if any combination of numbers in a list total a specific amount

Hi there,

I am trying figure out if any combination of numbers in a list adds up to a total specific amount, then if a match is found which are those numbers.

Example:

I have the following list; List of double (7) { 150.96, 54.85, 670.75, 1320.53, 594.96, 47.84, 1138.47 }

Then I have a string variable of (1,193.32)

What combination of numbers (if any) add up to the total in the string variable.

Any help on this would be greatly appreciated :slight_smile:

This would require calculating all possible combinations. You’d have to use something like this to calculate all the combinations, then loop through them and total each one up and compare to your string.

Hi,

Can you try the following sample?

Sample
Sample20240220-1.zip (3.0 KB)

This sample uses the following combination library.

It’s necessary to add nuget feed as the following.

 https://api.nuget.org/v3/index.json

Regards,

This is exactly what I needed, thank you so much!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.