In SQL I have a list of transaction types and a value. Simple example below.
|-----------|--------|
| Tran.Type | Value |
|-----------|--------|
| 04 | 10 |
|-----------|--------|
| 07 | 10 |
|-----------|--------|
| 04 | 5 |
|-----------|--------|
| 01 | 8 |
|-----------|--------|
|-----------------|
| Current Balance |
|-----------------|
| 13 |
|-----------------|
Goal is to sum values and get number 13. In this example is easy to find that type 07 is negative. So 10-10+5+8=13
But when number of transaction gets to 20 & 10 different types is quite difficult. Also values are positive & negative.
So far I came up with this.
import itertools
numbers = list(map(int, input("Enter multiple values: ").split()))
expectedSum = int(input("Enter expected value: "))
result = [seq for i in range(len(numbers), 0, -1) for seq in
itertools.combinations(numbers, i) if sum(seq) == expectedSum]
print (result)<code>
Any idea how can I incorporate type to result section? and if that type is an opposite value or not?