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: 599c333915e0ea32d04d4bec
|
||||
title: 元素操作
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
dashedName: element-wise-operations
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -168,5 +169,34 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function operation(op, arr1, arr2) {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function operation(op, arr1, arr2) {
|
||||
const ops = {
|
||||
add: ((a, b) => a + b),
|
||||
sub: ((a, b) => a - b),
|
||||
mult: ((a, b) => a * b),
|
||||
div: ((a, b) => a / b),
|
||||
exp: ((a, b) => Math.pow(a, b))
|
||||
};
|
||||
const ifm = op.startsWith('m');
|
||||
const doOp = ops[op.substring(2)];
|
||||
for (let i = 0; i < arr1.length; i++) {
|
||||
for (let j = 0; j < arr1[0].length; j++) {
|
||||
arr1[i][j] = doOp(arr1[i][j], (ifm) ? (arr2[i][j]) : (arr2));
|
||||
}
|
||||
}
|
||||
return arr1;
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user