I know how to create a code in python which actually can allow me to reach the desired number (target) with strings as input, now, what I don’t know how to do is to make this work:
I have a list with dimensions (0.15,0.30,0.45,0.60,0.90,1.20) and I know my target is 0.80.
How can I test the possible combinations of the existing dimensions to make sure that the difference between the target and the optimal combination is minimal?
I am new to Dynamo, so I have not been able to find how to reach the result with Nodes, and as I said before, I though about this on python, but it does not take me to the place i want.
def subset_sum(numbers, target, partial=):
s = sum(partial)
# this check if the partial sum is equals to target if s == target: print "sum(%s)=%s" % (partial, target) if s >= target: return for i in range(len(numbers)): n = numbers[i] remaining = numbers[i+1:] subset_sum(remaining, target, partial + [n])