Skip to content

Commit

Permalink
Redo coinSums.js using reduce in implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fay-jai committed Jan 14, 2015
1 parent 8ff52c2 commit 417fd1b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion coinSums/coinSums.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ var coinsAvailable = function (num) {
return coins.filter(function (n) {
return n <= num;
});
};
};

// Implementation using Reduce
// var makeChange = function (num) {
// var inner = function (num, coins) {
// if (num < 0) return 0;
// if (num === 0) return 1;
//
// return coins.reduce(function (acc, cur) {
// return acc + inner(num - cur, coinsAvailable(cur));
// }, 0);
// };
//
// return inner(num, coinsAvailable(num));
// };

0 comments on commit 417fd1b

Please sign in to comment.