Instead of returning a set of selected coins and their total value as separate items, encapsulate both of these, and other variables, into a new SelectionResult
struct. This allows us to have all of the things relevant to a coin selection solution be in a single object. SelectionResult
enables us to implement the waste calculation in a cleaner way.
All of the coin selection functions (SelectCoinsBnB
, KnapsackSolver
, AttemptSelection
, and SelectCoins
) are changed to use a SelectionResult
as the output parameter.
Based on #22009