diff --git a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/count-the-coins.md b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/count-the-coins.md index 5d900eb107..3e6bd14d1d 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/count-the-coins.md +++ b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/count-the-coins.md @@ -30,7 +30,7 @@ There are four types of common coins in [US](https://en.wikipedia.org/wiki/Unite # --instructions-- -Implement a function to determine how many ways there are to make change for a dollar using these common coins (1 dollar = 100 cents) +Implement a function to determine how many ways there are to make change for a given input, `cents`, that represents an amount of US pennies using these common coins. # --hints-- @@ -40,10 +40,22 @@ Implement a function to determine how many ways there are to make change for a d assert(typeof countCoins === 'function'); ``` -`countCoins()` should return 242. +`countCoins(15)` should return `6`. ```js -assert.equal(countCoins(), 242); +assert.equal(countCoins(15), 6); +``` + +`countCoins(85)` shouls return `163`. + +```js +assert.equal(countCoins(85), 163); +``` + +`countCoins(100)` should return `242`. + +```js +assert.equal(countCoins(100), 242); ``` # --seed-- @@ -51,7 +63,7 @@ assert.equal(countCoins(), 242); ## --seed-contents-- ```js -function countCoins() { +function countCoins(cents) { return true; } @@ -60,12 +72,11 @@ function countCoins() { # --solutions-- ```js -function countCoins() { - let t = 100; +function countCoins(cents) { const operands = [1, 5, 10, 25]; - const targetsLength = t + 1; + const targetsLength = cents + 1; const operandsLength = operands.length; - t = [1]; + const t = [1]; for (let a = 0; a < operandsLength; a++) { for (let b = 1; b < targetsLength; b++) {