fix: use the same solution format for subset-sum as for coin-change
This commit is contained in:
parent
91c4ca4dce
commit
9ef9a70c39
1 changed files with 2 additions and 8 deletions
|
|
@ -116,14 +116,8 @@ const getSolution_old = (units, amount, mode) => {
|
|||
|
||||
const solver = sumService.subsetSum(billList, amount.toNumber())
|
||||
const solution = _.countBy(Math.floor, solver.next().value)
|
||||
return _.reduce(
|
||||
(acc, value) => {
|
||||
acc.push({ denomination: _.toNumber(value), provisioned: solution[value] })
|
||||
return acc
|
||||
},
|
||||
[],
|
||||
_.keys(solution)
|
||||
)
|
||||
return Object.entries(solution)
|
||||
.map(([denomination, provisioned]) => [_.toNumber(denomination), provisioned])
|
||||
}
|
||||
|
||||
const getSolution = (units, amount) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue