fix(learn): rework Rosetta Code Count the Coins (#41282)
* fix: rework challenge to use argument in function * fix: use better wording Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@ -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++) {
|
||||
|
Reference in New Issue
Block a user