Given a hash of keys and numeric values and another integer value (target size), this module will select the largest keys from the given hash such that the sum of the selected keys is less than equal to the target size, or the sum of the selected keys will be closest to the target size but not exceeding it.
Library takes in a hash with a string as keys and a number as it’s value. This’s the second argument. After computation, it outputs the keys which has been selected to reach the target sum (first argument). Endpoint function – ClosestSum.calculate. ClosestSum is a module. Returns a hash of selected keys with their values. Returns TypeError exception if wrong arguments are sent.
e.g. – ClosestSum.calculate(998994, { sysadf: 8984, asdfiejf: 3434, asdokfjal: 89909 })