chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,50 +1,64 @@
---
id: a3f503de51cfab748ff001aa
title: 成对
title: Pairwise
challengeType: 5
videoUrl: ''
forumTopicId: 301617
dashedName: pairwise
---
# --description--
给定一个数组`arr` ,找到其总和等于第二个参数`arg`元素对,并返回它们的索引之和。您可以使用具有相同数字元素但索引不同的多个对。每对应使用尽可能低的可用指数。一旦元素被使用,它就不能被重用来与另一个元素配对。例如, `pairwise([1, 1, 2], 3)`使用indice 0处的1而不是indice 1处的1创建一对`[2, 1]` 因为0 + 2 <1 + 2。例如 `pairwise([7, 9, 11, 13, 15], 20)`返回`6` 。总和为20的对是`[7, 13]``[9, 11]` 。然后我们可以用它们的索引和值写出数组。
Given an array `arr`, find element pairs whose sum equal the second argument `arg` and return the sum of their indices.
| **指数** | 0 | 1 | 2 | 3 | 4 |
| ------ | - | - | -- | -- | -- |
| 值 | 7 | 9 | 11 | 13 | 15 |
You may use multiple pairs that have the same numeric elements but different indices. Each pair should use the lowest possible available indices. Once an element has been used it cannot be reused to pair with another element. For instance, `pairwise([1, 1, 2], 3)` creates a pair `[2, 1]` using the 1 at index 0 rather than the 1 at index 1, because 0+2 < 1+2.
下面我们将采用相应的索引并添加它们。 7 + 13 = 20→指数0 + 3 = 3
9 + 11 = 20→指数1 + 2 = 3
3 + 3 = 6→返回`6`如果卡住,请记住使用[Read-Search-Ask](https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514) 。尝试配对程序。编写自己的代码。
For example `pairwise([7, 9, 11, 13, 15], 20)` returns `6`. The pairs that sum to 20 are `[7, 13]` and `[9, 11]`. We can then write out the array with their indices and values.
<div style='margin-left: 2em;'>
| Index | 0 | 1 | 2 | 3 | 4 |
| ----- | - | - | -- | -- | -- |
| Value | 7 | 9 | 11 | 13 | 15 |
</div>
Below we'll take their corresponding indices and add them.
<div style='margin-left: 2em;'>
7 + 13 = 20 → Indices 0 + 3 = 3
9 + 11 = 20 → Indices 1 + 2 = 3
3 + 3 = 6 → Return `6`
</div>
# --hints--
`pairwise([1, 4, 2, 3, 0, 5], 7)`应该返回11
`pairwise([1, 4, 2, 3, 0, 5], 7)` should return 11.
```js
assert.deepEqual(pairwise([1, 4, 2, 3, 0, 5], 7), 11);
```
`pairwise([1, 3, 2, 4], 4)`应该返回1。
`pairwise([1, 3, 2, 4], 4)` should return 1.
```js
assert.deepEqual(pairwise([1, 3, 2, 4], 4), 1);
```
`pairwise([1, 1, 1], 2)`应该返回1。
`pairwise([1, 1, 1], 2)` should return 1.
```js
assert.deepEqual(pairwise([1, 1, 1], 2), 1);
```
`pairwise([0, 0, 0, 0, 1, 1], 1)`应返回10
`pairwise([0, 0, 0, 0, 1, 1], 1)` should return 10.
```js
assert.deepEqual(pairwise([0, 0, 0, 0, 1, 1], 1), 10);
```
`pairwise([], 100)`应该返回0。
`pairwise([], 100)` should return 0.
```js
assert.deepEqual(pairwise([], 100), 0);