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:
Oliver Eyton-Williams
2021-01-13 03:31:00 +01:00
committed by GitHub
parent 0095583028
commit ee1e8abd87
4163 changed files with 57505 additions and 10540 deletions

View File

@ -3,11 +3,12 @@ id: 59713bd26bdeb8a594fb9413
title: 计算硬币
challengeType: 5
videoUrl: ''
dashedName: count-the-coins
---
# --description--
<p> <a href='https://en.wikipedia.org/wiki/United_States' title='链接https//en.wikipedia.org/wiki/United_States'>美国</a>货币有四种常见硬币: </p>季度25美分硬币10美分5美分和便士1美分 <p>有六种方法可以换15美分 </p>一角钱和一角钱一角钱和5便士3镍2镍和5便士一镍和10便士15便士任务 <p>实现一个功能,以确定使用这些普通硬币改变一美元的方式有多少? 1美元= 100美分</p>参考: <a href='http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52' title='链接http//mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52'>麻省理工学院出版社的算法</a>
<p> <a href='https://en.wikipedia.org/wiki/United_States' title='链接https//en.wikipedia.org/wiki/United_States'>美国</a>货币有四种常见硬币: </p>季度25美分硬币10美分5美分和便士1美分 <p>有六种方法可以换15美分 </p>一角钱和一角钱一角钱和5便士3镍2镍和5便士一镍和10便士15便士任务 <p>实现一个功能,以确定使用这些普通硬币改变一美元的方式有多少? 1美元= 100美分</p>参考: <a href='http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52' title='链接http//mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52'>麻省理工学院出版社的算法</a>
# --hints--
@ -23,5 +24,37 @@ assert(typeof countCoins === 'function');
assert.equal(countCoins(), 242);
```
# --seed--
## --seed-contents--
```js
function countCoins() {
return true;
}
```
# --solutions--
```js
function countCoins() {
let t = 100;
const operands = [1, 5, 10, 25];
const targetsLength = t + 1;
const operandsLength = operands.length;
t = [1];
for (let a = 0; a < operandsLength; a++) {
for (let b = 1; b < targetsLength; b++) {
// initialise undefined target
t[b] = t[b] ? t[b] : 0;
// accumulate target + operand ways
t[b] += (b < operands[a]) ? 0 : t[b - operands[a]];
}
}
return t[targetsLength - 1];
}
```