I am trying to find an algorithm, but googling my exact problem does not find the exact result that I need.
I am assigned a set of numbers and a target amount. I need to assign numbers to groups so that the sum of these groups is as close as possible without going over the target value.
Example Target Sum = 99
Example Set = { 70, 40, 10, 70, 98, 14, 4, 7, 29, 11, 91, 50, 30 }
The desired results will be something like this:
{ 70, 29 }
{ 40, 50, 7}
{ 98 }
{ 91, 4 }
{ 70, 10, 11 }
{ 30, 14 }
... because they all make up a number close to 99.
The goal is to have as few groups as possible. I do not need to worry about resources. It will run sparingly, and the number of values will be quite low.
source
share