Find all subsets that sum to a particular value and then pick the most valuable combination of those subsets
问题 Im trying to create a simple dice game. To calculate the score i have to find all subsets that sum to a particular value and then pick the most valuable combination. All numbers can only be picked once. Probably easiest to describe with an example: Values = {1, 1, 1, 2, 4, 4} Target value = 5 Possible subsets = {1, 1, 1, 2} and {1, 4} Now its possible to either choose: {1, 1, 1, 2} (= worth 5) or {1, 4} {1, 4} (= worth 10) So in this example I would like the algorithm to return 10 and not 5 .