Based on this answer: https://stackoverflow.com/a/34517664/8793029
I want the same thing but being the variable target a range of floats, I need to find all possible combinations multiplying instead of sum to reach a given range, for example between 1.8 and 2.2. Also the list being a list of classes.
To explain better, it's like a class bet where every bet is playing against X casino odds. I have a list of bets, so I need to find all possible combinations of those bets to reach between 1.8 and 2.2 odds. Combinations should output as class bet arrays and not as float arrays. The problem really is that if I get as output a list of odds I don't know to which bet belongs.
This is what I would need more or less but doing it bad:
import itertools
import numpy
class myclass:
amount = 0.0
numbers = [myclass[1].amount, myclass[2].amount, myclass[3].amount, and so on...]
target = (1.8, 2.2)
result = [seq for i in range(len(numbers), 0, -1)
for seq in itertools.combinations(numbers, i)
if numpy.prod(seq).ISINRANGEOF(target)]
print(result)
How can I get all combinations of the given list to reach the desired range? So I can see all combinations of field amount being able to reach those classes individually, being result a list of possible combinations of my classes like:
print(result)
>> {myclass[2], myclass[1], myclass[3]}
Thanks in advance