For my program, I am trying to assist the user, and reduce his or her work load.
There are four input numbers. There is also an indeterminate amount of numbers they can be applied too.
For example, they four input numbers could be {4,7,3,2} and the numbers they can be applied to are {4,9,23}
The result should be: 4 (input)开发者_如何学运维 was applied to 4, leaving the sets looking like: {0,7,3,2} and then 7,2 (input) are applied to 9 leaving the sets looking like: {0,0,3,0} and {0,0,23} and because 3 or any other permutation including 3 does not match 23, 3 remains.
How would I do this?
Are you saying that you want to find the items from the input set that sum to a value in the other set? If so, then I believe this is an instance of the Subset Sum Problem, which is a special case of the Knapsack Problem.
Subset Sum is NP-Complete. If the sets are large, the best you will be able to do is an approximate solution.
精彩评论