feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0095583028
commit
ee1e8abd87
@ -3,6 +3,7 @@ id: 5900f38b1000cf542c50fe9e
|
||||
title: 问题31:硬币总和
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
dashedName: problem-31-coin-sums
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -43,5 +44,28 @@ assert(coinSums(150) == 21873);
|
||||
assert(coinSums(200) == 73682);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function coinSums(n) {
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
coinSums(200);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
const coinSums = (n) => {
|
||||
const getWays = (n, m=8, c=[1, 2, 5, 10, 20, 50, 100, 200]) => {
|
||||
if (n === 0) return 1;
|
||||
if (m === 0 || n < 0) return 0;
|
||||
return getWays(n - c[m - 1], m, c) + getWays(n, m - 1, c);
|
||||
};
|
||||
return getWays(n);
|
||||
};
|
||||
```
|
||||
|
Reference in New Issue
Block a user