0

In bank account I have values that can be the sum of one or more clients payments.

I Need to make a report with these individuals payments and check if there is a sum of some of this payments that matches the amount in a bank accounts report.

I'm using the itertools.permutatons, with the approach exposed here Text It appears to be working, except when the list of values exceeds 11 itens. It takes forever and doesn't finish the eval. Any other solution for this? I need to perform only sums evaluations.

In short i need to find which combinations of this values (if any)

[1001.0, 1000.0, 1598.0, 2000.0, 2000.0, 900.0, 900.0, 2350.0, 6200.0, 600.0, 390.0, 759.0, 1798.0, 2740.0, 1061.0, 978.0, 2750.0, 2825.0, 660.0, 887.0, 1710.0, 6368.0, 1475.0, 2700.0] 

matches 36706.0, for example. Looks like permutations generates too many combinations in this case so takes a eternity to finish.

Red
  • 26,798
  • 7
  • 36
  • 58
  • Please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – Maël Pedretti Apr 28 '21 at 13:19
  • Ordering should not matter, so you can use combinations instead of permutations. Also, you can immediately ignore combinations when part of them is bigger than the target value, and avoid searching deeper – mousetail Apr 28 '21 at 13:28
  • Does this answer your question? [Algorithm to find which number in a list sum up to a certain number](https://stackoverflow.com/q/3420937/6045800) – Tomerikoo Apr 29 '21 at 13:12

0 Answers0