chore(learn): Applied MDX format to Chinese curriculum files (#40462)

This commit is contained in:
Randell Dawson
2020-12-16 00:37:30 -07:00
committed by GitHub
parent 873fce02a2
commit 9ce4a02a41
1665 changed files with 58741 additions and 88042 deletions

View File

@ -1,66 +1,172 @@
---
id: 599c333915e0ea32d04d4bec
title: 元素操作
challengeType: 5
videoUrl: ''
title: 元素操作
---
## Description
<section id="description"><p>实现基本的元素矩阵 - 矩阵和标量矩阵运算。 </p><p>实行: </p><p> :: *另外</p><p> :: *减法</p><p> :: *乘法</p><p> :: *分裂</p><p> :: *取幂</p><p>第一个参数是要执行的操作例如用于矩阵加法的“m_add”和用于标量加法的“s_add”。第二和第三参数将是要在其上执行操作的矩阵。 </p></section>
# --description--
## Instructions
<section id="instructions">
</section>
<p>实现基本的元素矩阵 - 矩阵和标量矩阵运算。 </p><p>实行: </p><p> :: *另外</p><p> :: *减法</p><p> :: *乘法</p><p> :: *分裂</p><p> :: *取幂</p><p>第一个参数是要执行的操作例如用于矩阵加法的“m_add”和用于标量加法的“s_add”。第二和第三参数将是要在其上执行操作的矩阵。 </p>
## Tests
<section id='tests'>
# --hints--
```yml
tests:
- text: <code>operation</code>是一种功能。
testString: assert(typeof operation === 'function');
- text: <code>operation("m_add",[[1,2],[3,4]],[[1,2],[3,4]])</code>应返回<code>[[2,4],[6,8]]</code> 。
testString: assert.deepEqual(operation('m_add', [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[2, 4], [6, 8]]);
- text: <code>operation("s_add",[[1,2],[3,4]],[[1,2],[3,4]])</code>应返回<code>[[3,4],[5,6]]</code> 。
testString: assert.deepEqual(operation('s_add', [[1, 2], [3, 4]], 2), [[3, 4], [5, 6]]);
- text: <code>operation("m_sub",[[1,2],[3,4]],[[1,2],[3,4]])</code>应返回<code>[[0,0],[0,0]]</code> 。
testString: assert.deepEqual(operation('m_sub', [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[0, 0], [0, 0]]);
- text: <code>operation("m_mult",[[1,2],[3,4]],[[1,2],[3,4]])</code>应该返回<code>[[1,4],[9,16]]</code> 。
testString: assert.deepEqual(operation('m_mult', [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 4], [9, 16]]);
- text: <code>operation("m_div",[[1,2],[3,4]],[[1,2],[3,4]])</code>应返回<code>[[1,1],[1,1]]</code> 。
testString: assert.deepEqual(operation('m_div', [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 1], [1, 1]]);
- text: <code>operation("m_exp",[[1,2],[3,4]],[[1,2],[3,4]])</code>应返回<code>[[1,4],[27,256]]</code> 。
testString: assert.deepEqual(operation('m_exp', [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 4], [27, 256]]);
- text: <code>operation("m_add",[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]])</code>应该返回<code>[[10,12,14,16],[18,20,22,24]]</code> 。
testString: assert.deepEqual(operation('m_add', [[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]), [[10, 12, 14, 16], [18, 20, 22, 24]]);
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
`operation`是一种功能。
```js
function operation (op, arr1, arr2) {
// Good luck!
}
assert(typeof operation === 'function');
```
</div>
</section>
## Solution
<section id='solution'>
`operation("m_add",[[1,2],[3,4]],[[1,2],[3,4]])`应返回`[[2,4],[6,8]]`
```js
// solution required
assert.deepEqual(
operation(
'm_add',
[
[1, 2],
[3, 4]
],
[
[1, 2],
[3, 4]
]
),
[
[2, 4],
[6, 8]
]
);
```
/section>
`operation("s_add",[[1,2],[3,4]],[[1,2],[3,4]])`应返回`[[3,4],[5,6]]`
```js
assert.deepEqual(
operation(
's_add',
[
[1, 2],
[3, 4]
],
2
),
[
[3, 4],
[5, 6]
]
);
```
`operation("m_sub",[[1,2],[3,4]],[[1,2],[3,4]])`应返回`[[0,0],[0,0]]`
```js
assert.deepEqual(
operation(
'm_sub',
[
[1, 2],
[3, 4]
],
[
[1, 2],
[3, 4]
]
),
[
[0, 0],
[0, 0]
]
);
```
`operation("m_mult",[[1,2],[3,4]],[[1,2],[3,4]])`应该返回`[[1,4],[9,16]]`
```js
assert.deepEqual(
operation(
'm_mult',
[
[1, 2],
[3, 4]
],
[
[1, 2],
[3, 4]
]
),
[
[1, 4],
[9, 16]
]
);
```
`operation("m_div",[[1,2],[3,4]],[[1,2],[3,4]])`应返回`[[1,1],[1,1]]`
```js
assert.deepEqual(
operation(
'm_div',
[
[1, 2],
[3, 4]
],
[
[1, 2],
[3, 4]
]
),
[
[1, 1],
[1, 1]
]
);
```
`operation("m_exp",[[1,2],[3,4]],[[1,2],[3,4]])`应返回`[[1,4],[27,256]]`
```js
assert.deepEqual(
operation(
'm_exp',
[
[1, 2],
[3, 4]
],
[
[1, 2],
[3, 4]
]
),
[
[1, 4],
[27, 256]
]
);
```
`operation("m_add",[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]])`应该返回`[[10,12,14,16],[18,20,22,24]]`
```js
assert.deepEqual(
operation(
'm_add',
[
[1, 2, 3, 4],
[5, 6, 7, 8]
],
[
[9, 10, 11, 12],
[13, 14, 15, 16]
]
),
[
[10, 12, 14, 16],
[18, 20, 22, 24]
]
);
```
# --solutions--