diff --git a/lib/coin-change.js b/lib/coin-change.js index 1c9eab5e..4a1c964a 100644 --- a/lib/coin-change.js +++ b/lib/coin-change.js @@ -24,11 +24,6 @@ const prepare_denominations = denominations => const max_denomination_multiplicity = (denom, count, target) => Math.min(count, Math.floor(target / denom)) -const has_divisor = (didx, denominations, target) => - denominations - .slice(didx) - .some(({ denom }) => (target % denom) === 0) - /* * @returns null if there's no solution set; * false if there's no solution; @@ -78,7 +73,7 @@ const solve = (model, target) => { * of the denominations, or if the target is not divisible by any of the * denominations */ - if (target > csum || !has_divisor(didx, denominations, target)) + if (target > csum) return memo_set(memo, target, denom, false) let solution = memo_get(memo, target, denom)