Merge pull request #1619 from siiky/fix/lam-990/use-getSolution
LAM-990 use `getSolution`
This commit is contained in:
commit
16c0061a9c
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
const _ = require('lodash/fp')
|
||||
const sumService = require('@haensl/subset-sum')
|
||||
|
||||
const BN = require('./bn')
|
||||
const logger = require('./logger')
|
||||
const cc = require('./coin-change')
|
||||
|
||||
|
|
@ -152,9 +153,9 @@ const solutionToOriginalUnits = (solution, units) => {
|
|||
|
||||
function makeChange(outCassettes, amount) {
|
||||
const ss_solution = getSolution_old(outCassettes, amount, BILL_LIST_MODES.VALUE_ROUND_ROBIN)
|
||||
const cc_solution = cc.solve(cc.model(outCassettes), amount.toNumber())
|
||||
const cc_solution = getSolution(outCassettes, amount)
|
||||
|
||||
if (!!ss_solution === !!cc_solution) {
|
||||
if (!!ss_solution !== !!cc_solution) {
|
||||
logger.error(new Error(`subset-sum and coin-change don't agree on solvability -- subset-sum:${!!ss_solution} coin-change:${!!cc_solution}`))
|
||||
return solutionToOriginalUnits(ss_solution, outCassettes)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue