chore(i18n,curriculum): update translations (#43463)

This commit is contained in:
camperbot
2021-09-18 11:22:53 -07:00
committed by GitHub
parent 81d48b26ad
commit 15be1fe6bb
164 changed files with 1081 additions and 372 deletions

View File

@ -1,6 +1,6 @@
---
id: 587d825a367417b2b2512c89
title: Implement Quick Sort
title: 實現快速排序
challengeType: 1
forumTopicId: 301615
dashedName: implement-quick-sort
@ -8,21 +8,21 @@ dashedName: implement-quick-sort
# --description--
Here we will move on to an intermediate sorting algorithm: quick sort. Quick sort is an efficient, recursive divide-and-conquer approach to sorting an array. In this method, a pivot value is chosen in the original array. The array is then partitioned into two subarrays of values less than and greater than the pivot value. We then combine the result of recursively calling the quick sort algorithm on both sub-arrays. This continues until the base case of an empty or single-item array is reached, which we return. The unwinding of the recursive calls return us the sorted array.
在這裏,我們將繼續討論中間排序算法:快速排序。 快速排序是對數組進行排序的一種有效的,遞歸的分而治之的方法。 在此方法中,在原始數組中選擇一個樞軸值。 然後將該數組分成兩個小於和大於數值的子數組。 然後,我們在兩個子陣列上結合遞歸調用快速排序算法的結果。 這一直持續到達到空或單項數組的基本情況,我們返回。 遞歸調用的展開將返回已排序的數組。
Quick sort is a very efficient sorting method, providing *O(nlog(n))* performance on average. It is also relatively easy to implement. These attributes make it a popular and useful sorting method.
快速排序是一種非常有效的排序方法,平均提供 *O(nlog(n))* 的性能。 它也相對容易實現。 這些屬性使其成爲一種流行且有用的排序方法。
**Instructions:** Write a function `quickSort` which takes an array of integers as input and returns an array of these integers in sorted order from least to greatest. While the choice of the pivot value is important, any pivot will do for our purposes here. For simplicity, the first or last element could be used.
**說明:** 編寫一個函數 `quickSort`,它將整數數組作爲輸入,並按從最小到最大的排序順序返回這些整數的數組。 雖然樞軸值的選擇很重要,但任何樞軸都可以滿足我們的目的。 爲簡單起見,可以使用第一個或最後一個元素。
# --hints--
`quickSort` should be a function.
`quickSort` 應該是一個函數。
```js
assert(typeof quickSort == 'function');
```
`quickSort` should return a sorted array (least to greatest).
`quickSort` 應該返回一個排序的數組(從最小到最大)。
```js
assert(
@ -50,7 +50,7 @@ assert(
);
```
`quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])` should return an array that is unchanged except for order.
`quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])` 應該返回一個數組,除了順序之外沒有變化。
```js
assert.sameMembers(
@ -77,7 +77,7 @@ assert.sameMembers(
);
```
`quickSort` should not use the built-in `.sort()` method.
`quickSort` 不應使用內置的 `.sort()` 方法。
```js
assert(isBuiltInSortUsed());

View File

@ -1,6 +1,6 @@
---
id: a56138aff60341a09ed6c480
title: Inventory Update
title: 庫存更新
challengeType: 5
forumTopicId: 16019
dashedName: inventory-update
@ -8,11 +8,11 @@ dashedName: inventory-update
# --description--
Compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in `arr1`). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical order by item.
將存儲在二維數組中的庫存與新交貨的二維數組進行比較和更新。 更新當前現有庫存物料數量(在 `arr1`)。 如果找不到商品,請將新商品和數量添加到庫存數組中。 返回的庫存數組應按項目的字母順序排列。
# --hints--
The function `updateInventory` should return an array.
函數 `updateInventory` 應該返回一個數組。
```js
assert.isArray(
@ -33,7 +33,7 @@ assert.isArray(
);
```
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return an array with a length of 6.
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 應該返回一個長度爲 6 的數組。
```js
assert.equal(
@ -55,7 +55,7 @@ assert.equal(
);
```
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return `[[88, "Bowling Ball"], [2, "Dirty Sock"], [3, "Hair Pin"], [3, "Half-Eaten Apple"], [5, "Microphone"], [7, "Toothpaste"]]`.
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 應返回`[[88, "Bowling Ball"], [2, "Dirty Sock"], [3, "Hair Pin"], [3, "Half-Eaten Apple"], [5, "Microphone"], [7, "Toothpaste"]]`
```js
assert.deepEqual(
@ -84,7 +84,7 @@ assert.deepEqual(
);
```
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [])` should return `[[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]]`.
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [])`應該返回`[[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]]`
```js
assert.deepEqual(
@ -106,7 +106,7 @@ assert.deepEqual(
);
```
`updateInventory([], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return `[[67, "Bowling Ball"], [2, "Hair Pin"], [3, "Half-Eaten Apple"], [7, "Toothpaste"]]`.
`updateInventory([], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 應該返回 `[[67, "Bowling Ball"], [2, "Hair Pin"], [3, "Half-Eaten Apple"], [7, "Toothpaste"]]`
```js
assert.deepEqual(
@ -128,7 +128,7 @@ assert.deepEqual(
);
```
`updateInventory([[0, "Bowling Ball"], [0, "Dirty Sock"], [0, "Hair Pin"], [0, "Microphone"]], [[1, "Hair Pin"], [1, "Half-Eaten Apple"], [1, "Bowling Ball"], [1, "Toothpaste"]])` should return `[[1, "Bowling Ball"], [0, "Dirty Sock"], [1, "Hair Pin"], [1, "Half-Eaten Apple"], [0, "Microphone"], [1, "Toothpaste"]]`.
`updateInventory([[0, "Bowling Ball"], [0, "Dirty Sock"], [0, "Hair Pin"], [0, "Microphone"]], [[1, "Hair Pin"], [1, "Half-Eaten Apple"], [1, "Bowling Ball"], [1, "Toothpaste"]])` 應返回 `[[1, "Bowling Ball"], [0, "Dirty Sock"], [1, "Hair Pin"], [1, "Half-Eaten Apple"], [0, "Microphone"], [1, "Toothpaste"]]`
```js
assert.deepEqual(