How to Get Combination Range
10/22/24About 2 min
Background
There are three variables, name target,candidate and others,
- The range of
targetis . - The range of
candidateis . - The range of
othersis .
There is a relationshp:
Now give the range of target candidate and others.
Solution
Step 1: Find the value of
candidate .Step 2:
Step 3:
Step 4:
Range 1:
Range 2:
Range 3:
Range 4:
Step 5:
- select a value
vin available ranges forcandidate, - update date
targetto [x1-v, x2-v] - select one element from others as
candidateand remove it fromothers
- if
othersis not empty,
4. updateothersas the sum of others elements (except newcandidateelement)
5. Go to Step 1. - else go to Step 6.
- select a value
Step 6:
select a random value from the intersection oftargetandcandidate.
