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: 5951ed8945deab770972ae56
|
||||
title: 河内的塔
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
dashedName: towers-of-hanoi
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -45,5 +46,40 @@ assert.deepEqual(res5[9], ['Y', 'X']);
|
||||
assert.deepEqual(towerOfHanoi(7, 'A', 'B', 'C').slice(0, 10), res7First10Moves);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```js
|
||||
const res3 = towerOfHanoi(3, 'A', 'B', 'C');
|
||||
const res3Moves = [['A', 'B'], ['A', 'C'], ['B', 'C'], ['A', 'B'], ['C', 'A'], ['C', 'B'], ['A', 'B']];
|
||||
const res5 = towerOfHanoi(5, 'X', 'Y', 'Z');
|
||||
const res7First10Moves = [['A', 'B'], ['A', 'C'], ['B', 'C'], ['A', 'B'], ['C', 'A'], ['C', 'B'], ['A', 'B'], ['A', 'C'], ['B', 'C'], ['B', 'A']];
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function towerOfHanoi(n, a, b, c) {
|
||||
|
||||
return [[]];
|
||||
}
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function towerOfHanoi(n, a, b, c) {
|
||||
const res = [];
|
||||
towerOfHanoiHelper(n, a, c, b, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
function towerOfHanoiHelper(n, a, b, c, res) {
|
||||
if (n > 0) {
|
||||
towerOfHanoiHelper(n - 1, a, c, b, res);
|
||||
res.push([a, c]);
|
||||
towerOfHanoiHelper(n - 1, b, a, c, res);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user