Stonk
(Josh Harris)
February 20, 2024, 2:18am
1
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

postwick
(Paul)
February 20, 2024, 2:31am
2
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.

vb.net

Yoichi
(Yoichi)
February 20, 2024, 3:01am
3
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,

Stonk
(Josh Harris)
February 20, 2024, 7:28am
4
This is exactly what I needed, thank you so much!

1 Like

system
(system)
Closed
February 23, 2024, 7:28am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.