diff --git a/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md b/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md index fedfc3f26d..a1d3679bc8 100644 --- a/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md +++ b/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md @@ -8,27 +8,25 @@ dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-c # --description-- -你可能已經注意到一些 freeCodeCamp JavaScript 的挑戰有自己的控制檯。 這些控制檯的行爲與上一次挑戰中使用的瀏覽器控制檯略有不同。 +你可能已經注意到一些 freeCodeCamp 的挑戰有自己的控制檯。 這個控制檯的行爲與瀏覽器控制檯有些不同。 -以下挑戰旨在強調 freeCodeCamp 控制檯與瀏覽器控制檯之間的一些差異。 - -當在瀏覽器中加載並運行 JavaScript 文件時,`console.log()` 語句會在控制檯中按照調用的次數準確地打印出要求的內容。 - -在編輯器檢測到腳本中的更改之後,以及測試期間,freeCodeCamp 控制檯將打印 `console.log()` 語句。 - -在運行測試之前,將清除 freeCodeCamp 控制檯,爲避免破壞,僅在第一次測試期間打印日誌(請參見下面的註釋)。 - -如果你想看到每次測試的日誌,運行測試,並打開瀏覽器控制檯。 如果你喜歡使用瀏覽器控制檯,想要它模仿 freeCodeCamp 控制檯,請在其他 `console` 調用前加上 `console.clear()`,以清除瀏覽器控制檯。 - -**注意:** 每次調用函數時,函數內的 `console.log` 都會被打印到 freeCodeCamp 控制檯。 這樣可以幫助在測試期間調試函數。 +有許多方法可以與 `console` 一起使用來輸出消息。 `log`、`warn` 和 `clear` 就是幾個例子。 freeCodeCamp 控制檯只會輸出 `log` 消息,而瀏覽器控制檯會輸出所有消息。 當你對你的代碼進行修改時,它將自動運行並顯示日誌。 每次代碼運行時,freeCodeCamp 控制檯都會被清除。 # --instructions-- -首先,使用 `console.log` 打印 `output` 變量。 然後使用 `console.clear` 清除瀏覽器控制檯。 +首先,打開瀏覽器控制檯,以便查看日誌。 要做到這一點,在大多數瀏覽器上,你可以右擊頂部的 freeCodeCamp 導航欄,並點擊 `inspect`。 然後在打開的窗口中找到 `console` 選項卡。 + +之後,使用 `console.log` 記錄 `output` 變量。 查看這兩個控制檯,可以看到日誌。 最後,在你的日誌後面使用 `console.clear` 清除瀏覽器控制檯。 查看兩個控制檯的差異。 # --hints-- -應該使用 `console.clear()` 清除瀏覽器控制檯。 +你應該使用 `console.log()` 來打印 `output` 變量。 + +```js +assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +``` + +你應該使用 `console.clear()` 來清除瀏覽器控制檯。 ```js assert( @@ -38,10 +36,14 @@ assert( ); ``` -應該使用 `console.log()` 打印 `output` 變量。 +你應該在你的日誌之後清除控制檯。 ```js -assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +assert( + __helpers + .removeWhiteSpace(code) + .match(/console\.log\(output\)[\s\S]*console.clear\(\)/) +); ``` # --seed-- @@ -49,25 +51,15 @@ assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); ## --seed-contents-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. ``` # --solutions-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. -console.clear(); +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; + console.log(output); - -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. +console.clear(); ``` diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md index ad2b8eb04d..71ede24384 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md @@ -10,29 +10,37 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me 請注意,本項目在[這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基礎上進行開發。你也可以從 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -接下來,我們將瞭解如何使用請求的 payload(body)發送數據。 我們需要測試一個 PUT 請求, `'/travellers'` 接收如下的 JSON 對象: +當你測試一個 `PUT` 請求時,你經常會隨同它一起發送數據。 你在 `PUT` 請求中包含的數據被稱爲請求的主體。 + +要將 `PUT` 請求和 JSON 對象發送到 `'/travellers'` 端點,你可以使用 `chai-http` 插件的 `put` 和 `send` 方法: + +```js +chai + .request(server) + .put('/travellers') + .send({ + "surname": [last name of a traveller of the past] + }) + ... +``` + +並且路由響應如下: ```json { - "surname": [last name of a traveller of the past] + "name": [first name], + "surname": [last name], + "dates": [birth - death years] } ``` -路由響應如下: - -```json -{ - "name": [first name], "surname": [last name], "dates": [birth - death years] -} -``` - -更多細節請查看服務器代碼。 +請參閱服務器代碼以瞭解對 `'/travellers'` 端點的不同響應。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "Colombo"}'` 測試(`// #3`): +在 `tests/2_functional-tests.js` 中,更改 `'Send {surname: "Colombo"}'` 測試(`// #3`),並使用 `put` 和 `send` 方法來測試 `'/travellers'` 端點。 -發送以下 JSON 響應作爲有效載荷: +在你的 PUT 請求中發送以下 JSON 對象。 ```json { @@ -40,14 +48,14 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me } ``` -在 `request.end` 返回中檢查以下情況: +在 `request.end` 的返回中檢查以下情況: -1. `status` -2. `type` -3. `body.name` -4. `body.surname` +1. `status` 應該是 `200` +2. `type` 應該是 `application/json` +3. `body.name` 應該是 `Cristoforo` +4. `body.surname` 應該是 `Colombo` -請按照以上順序書寫斷言,順序錯誤會影響系統判定。 完成後,請務必移除 `assert.fail()`。 +請按照以上順序書寫斷言,順序錯誤會影響系統判定。 此外,請確保在完成後刪除 `assert.fail()`。 # --hints-- @@ -65,7 +73,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -應測試 “res.status” 是否爲 200。 +應該測試 `res.status` 爲 200。 ```js (getUserInput) => @@ -81,7 +89,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要測試 “res.type” 是否爲 “application/json”。 +應該測試 `res.type` 是否爲 `'application/json'`。 ```js (getUserInput) => @@ -97,7 +105,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要測試 “res.body.name” 是否爲 “Cristoforo”。 +你應該測試 `res.body.name` 是否爲 `'Cristoforo'`。 ```js (getUserInput) => @@ -113,7 +121,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要測試 “res.body.surname” 是否爲 “Colombo”。 +你應該測試 `res.body.surname` 是否爲 `'Colombo'`。 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md index db2f72810b..f79a74e224 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md @@ -8,15 +8,17 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met # --description-- -請注意,本項目在[這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基礎上進行開發。你也可以從 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 這個練習與上一個類似, 我們詳細看看。 +請注意,本項目在 [這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) 的基礎上進行開發。你也可以從 [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) 上克隆。 -你已經看到了它是如何完成的,現在你需要從零開始搭建。 +這個練習與上一個類似。 + +現在你知道如何測試一個 `PUT` 請求了,輪到你從頭開始做了。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "da Verrazzano"}'` 測試(`// #4`)。 +在 `tests/2_functional-tests.js` 中,更改 `'Send {surname: "da Verrazzano"}'` 測試(`// #4`)並使用 `put` 和 `send` 方法來測試 `'/travellers'` 端點。 -發送以下 JSON 響應作爲有效載荷到 `/travellers` 路徑: +在你的 PUT 請求中發送以下 JSON 對象。 ```json { @@ -24,18 +26,18 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met } ``` -在 `request.end` 返回中檢查以下情況: +在 `request.end` 的返回中檢查以下情況: -1. `status` -2. `type` -3. `body.name` -4. `body.surname` +1. `status` 應該是 `200` +2. `type` 應該是 `application/json` +3. `body.name` 應該是 `Giovanni` +4. `body.surname` 應該是 `da Verrazzano` -請按照以上順序書寫斷言,順序錯誤會影響系統判定。 完成後請務必刪除 `assert.fail()`。 +請按照以上順序書寫斷言,順序錯誤會影響系統判定。 此外,請確保在完成後刪除 `assert.fail()`。 # --hints-- -需要通過所有測試。 +應通過所有測試。 ```js (getUserInput) => @@ -49,7 +51,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要測試 “res.status” 是否爲 200。 +應該測試 `res.status` 爲 200。 ```js (getUserInput) => @@ -65,7 +67,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要測試 “res.type” 是否爲 “application/json”。 +應該測試 `res.type` 是否爲 `'application/json'`。 ```js (getUserInput) => @@ -81,7 +83,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要測試 “res.body.name” 爲 “Giovanni”。 +應該測試 `res.body.name` 是否爲 `'Giovanni'` ```js (getUserInput) => @@ -97,7 +99,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要測試 “res.body.surname” 是否爲 “da Verrazzano”。 +應該測試 `res.body.surname` 是否爲 `'da Verrazzano'` ```js (getUserInput) => diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md index 4482d2c9d9..48251c3a74 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md @@ -12,9 +12,9 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with your name'` 測試(`// #2`),對 `status` 和 `text` 斷言。 +在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with your name'` 測試(`// #2`),對響應的 `status` 和 `text` 使用斷言來通過測試。 -在查詢中發送 name,將 `?name=` 添加到路由。 端點響應 `'hello '`。 +通過將 `?name=` 附加到路由,將你的姓名作爲 URL 查詢發送。 端點響應 `'hello '`。 # --hints-- @@ -32,7 +32,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii ); ``` -應測試 “res.status” 是否爲 200。 +應該測試 `res.status` 爲 200 ```js (getUserInput) => @@ -48,7 +48,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii ); ``` -應測試 “res.text“ 是否爲 ”hello Guest“。 +應該測試 `res.text` == `'hello '` ```js (getUserInput) => diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md index 22a109720d..207471c9c2 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md @@ -10,37 +10,36 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http 請注意,本項目在[這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基礎上進行開發。你也可以從 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -Mocha 允許測試異步操作。 有一個差異, 你能發現它嗎? +Mocha 允許你使用名爲 `chai-http` 的插件測試異步操作,例如調用 API 端點。 -我們可以使用一個叫作 `chai-http` 的插件測試 API 端點。 讓我們看看它是如何工作的。 請記住,API 調用是異步的。 - -以下是使用 `chai-http` 測試 `'GET /hello?name=[name] => "hello [name]"'` 套件的例子。 測試通過 `GET` 請求在 url 查詢字符串 `?name=John` 中發送一個名稱字符串給 `server`。 在 `end` 方法的回調函數中,接收包含 `status` 屬性的響應對象(`res`)。 第一個 `assert.equal` 檢查狀態是否爲 `200`。 第二個 `assert.equal` 檢查響應字符串 `res.text` 是否爲 `"hello John"`。 +以下是使用 `chai-http` 測試名爲 `'GET /hello?name=[name] => "hello [name]"'` 的套件的示例: ```js suite('GET /hello?name=[name] => "hello [name]"', function () { - test("?name=John", function (done) { + test('?name=John', function (done) { chai .request(server) - .get("/hello?name=John") + .get('/hello?name=John') .end(function (err, res) { - assert.equal(res.status, 200, "response status should be 200"); - assert.equal( - res.text, - "hello John", - 'response should be "hello John"' - ); + assert.equal(res.status, 200, 'Response status should be 200'); + assert.equal(res.text, 'hello John', 'Response should be "hello John"'); done(); }); }); +}); ``` -請注意測試的回調函數中的 `done` 參數。 在沒有傳入參數的情況下調用它,是成功完成異步任務所必需的。 +該測試向服務器發送一個 `GET` 請求,並將名稱作爲 URL 查詢字符串(`?name=John`)。 在`end` 方法的回調函數中,接收到響應對象(`res`)幷包含 `status` 屬性。 + +第一個 `assert.equal` 檢查狀態是否爲 `200`。 第二個 `assert.equal` 檢查響應字符串(`res.text`)是否爲 `"hello John"`。 + +同時,請注意測試的回調函數中的 `done` 參數。 在測試結束時,調用它且不帶參數,是發出異步操作完成所必需的信號。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with no name'` 測試(`// #1`),對 `status` 和 `text` 使用斷言。 不要修改傳給斷言的參數。 +在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with no name'` 測試(`// #1`),對響應的 `status` 和 `text` 使用斷言來通過測試。 不要改變傳遞給斷言的參數。 -不要在 query 中傳入 name,端點將會返回 `hello Guest`。 +不應該有任何 URL 查詢。 如果沒有名稱 URL 查詢,端點將使用 `hello Guest` 進行響應。 # --hints-- @@ -58,7 +57,7 @@ suite('GET /hello?name=[name] => "hello [name]"', function () { ); ``` -應測試 “res.status” 是否爲 200。 +應該測試 `res.status` 爲 200。 ```js (getUserInput) => @@ -74,7 +73,7 @@ suite('GET /hello?name=[name] => "hello [name]"', function () { ); ``` -應測試 “res.text“ 是否爲 ”hello Guest“。 +應該測試 `res.text` == `'hello Guest'`。 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md index 8434d7d9db..f9cef3d4a7 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md @@ -12,17 +12,17 @@ dashedName: run-functional-tests-using-a-headless-browser-ii # --instructions-- -在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Vespucci" - write your e2e test...'` 測試(`// #6`),自動化填寫和提交表單: +在 `tests/2_functional-tests.js` 中,在 `'Submit the surname "Vespucci" in the HTML form'` 測試(`// #5`),自動執行以下操作: -1. 在表單中填寫 `Vespucci` 的 `surname`。 -2. 點擊 `'submit'` 按鈕提交表單 +1. 在表格中填寫姓氏 `Vespucci`。 +2. 點擊提交按鈕 -在回調中: +在 `pressButton` 回調中: -1. 斷言狀態是正常的 `200` -2. 斷言元素 `span#name` 中的文本是 `'Amerigo'` -3. 斷言元素 `span#surname` 元素中的文本是 `'Vespucci'` -4. 斷言有 `span#dates` 元素,它們的計數是 `1` +1. 斷言狀態是正常的 `200`。 +2. 斷言元素 `span#name` 中的文本是 `'Amerigo'`。 +3. 斷言元素 `span#surname` 元素中的文本是 `'Vespucci'`。 +4. 斷言有 `span#dates` 元素,它們的計數是 `1`。 不要忘記刪除 `assert.fail()` 調用。 @@ -32,7 +32,7 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.state, 'passed'); }, @@ -46,7 +46,7 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[0].method, 'browser.success'); }, @@ -56,11 +56,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -應斷言元素 “span#surname” 中的文本爲 “Vespucci”。 +應斷言元素 `span#name` 中的文本是 `'Amerigo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[1].method, 'browser.text'); assert.match(data.assertions[1].args[0], /('|")span#name\1/); @@ -72,11 +72,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -應斷言元素 “span#surname” 中的文本爲 “Vespucci”。 +應斷言元素 `span#surname` 中的文本是 `'Vespucci'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[2].method, 'browser.text'); assert.match(data.assertions[2].args[0], /('|")span#surname\1/); @@ -88,11 +88,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -應該斷言元素 “span#dates” 存在,且它的值爲 1。 +應該斷言元素 `span#dates` 存在,且它的值爲 1。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[3].method, 'browser.elements'); assert.match(data.assertions[3].args[0], /('|")span#dates\1/); diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md index d2b5263446..b7ecb5c966 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md @@ -10,23 +10,31 @@ dashedName: run-functional-tests-using-a-headless-browser 請注意,本項目在[這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基礎上進行開發。你也可以從 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -在 HTML 主視圖中有一個輸入表格。 它發送數據到 `PUT /travellers` 端點,我們在上面的 Ajax 請求中使用。 當請求成功完成時,客戶端代碼會給 DOM 增加一個包含調用返回信息的 `
`。 下面的例子展示瞭如何使用這個表格: +在頁面上有一個輸入表單。 它將數據作爲 AJAX 請求發送到 `PUT /travellers` 端點。 + +當請求成功完成後,客戶端代碼將一個包含響應信息的 `
` 附加到 DOM 中。 + +下面是一個如何使用 Zombie.js 與表單互動的例子。 ```js -test('#test - submit the input "surname" : "Polo"', function (done) { - browser.fill('surname', 'Polo').pressButton('submit', function () { - browser.assert.success(); - browser.assert.text('span#name', 'Marco'); - browser.assert.text('span#surname', 'Polo'); - browser.assert.elements('span#dates', 1); - done(); +test('Submit the surname "Polo" in the HTML form', function (done) { + browser.fill('surname', 'Polo').then(() => { + browser.pressButton('submit', () => { + browser.assert.success(); + browser.assert.text('span#name', 'Marco'); + browser.assert.text('span#surname', 'Polo'); + browser.assert.elements('span#dates', 1); + done(); + }); }); -} +}); ``` -首先, `browser` 對象的 `fill` 方法在表格的 `surname` 字段中填入值 `'Polo'`。 緊接着,`pressButton` 方法調用表單的 `submit` 事件監聽器。 `pressButton` 方法是異步的。 +首先, `browser` 對象的 `fill` 方法在表格的 `surname` 字段中填入值 `'Polo'`。 `fill` 返回一個 promise,所以 `then` 被鏈接起來。 -收到 AJAX 請求的響應之後,會有幾項斷言確認: +在 `then` 回調中,`browser` 對象的 `pressButton` 方法用於調用表單的 `submit` 的事件偵聽器。 `pressButton` 方法是異步的。 + +然後,一旦收到來自 AJAX 請求的響應,就會做出一些斷言來確認: 1. 響應狀態是 `200` 2. `` 元素的文本是 `'Marco'` @@ -37,17 +45,17 @@ test('#test - submit the input "surname" : "Polo"', function (done) { # --instructions-- -在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Colombo" - write your e2e test...'` 測試(`// #5`),自動化填入和提交表單: +在 `tests/2_functional-tests.js` 中,在 `'Submit the surname "Colombo" in the HTML form'` 測試(`// #5`),自動執行以下操作: -1. 填寫表單 -2. 點擊 `'submit'` 按鈕提交表單 +1. 在表格中填寫姓氏 `Colombo`。 +2. 點擊提交按鈕 -在回調中: +在 `pressButton` 回調中: -1. 斷言狀態是正常的 `200` -2. 斷言元素 `span#name` 中的文本是 `'Cristoforo'` -3. 斷言元素 `span#surname` 元素中的文本是 `'Colombo'` -4. 斷言有 `span#dates` 元素,它們的計數是 `1` +1. 斷言狀態是正常的 `200`。 +2. 斷言元素 `span#name` 中的文本是 `'Cristoforo'`。 +3. 斷言元素 `span#surname` 中的文本是 `'Colombo'`。 +4. 斷言有 `span#dates` 元素,它們的計數是 `1`。 不要忘記刪除 `assert.fail()` 調用。 @@ -57,7 +65,7 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.state, 'passed'); }, @@ -67,11 +75,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -應該斷言無頭瀏覽器請求成功。 +應斷言無頭瀏覽器成功執行請求。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[0].method, 'browser.success'); }, @@ -81,11 +89,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -應該斷言元素 “span#name” 中的文字爲 “Cristoforo”。 +應斷言元素 `span#name` 中的文本是 `'Cristoforo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[1].method, 'browser.text'); assert.match(data.assertions[1].args[0], /('|")span#name\1/); @@ -97,11 +105,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -應該斷言元素 “span#surname” 中的文字爲 “Colombo”。 +應斷言元素 `span#surname` 中的文本是 `'Colombo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[2].method, 'browser.text'); assert.match(data.assertions[2].args[0], /('|")span#surname\1/); @@ -113,11 +121,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -應該斷言元素 “span#dates” 存在,且它的值爲 1。 +應該斷言元素 `span#dates` 存在,且它的值爲 1。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[3].method, 'browser.elements'); assert.match(data.assertions[3].args[0], /('|")span#dates\1/); diff --git a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md index 9110c627bf..10c84675e0 100644 --- a/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md +++ b/curriculum/challenges/chinese-traditional/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md @@ -9,37 +9,35 @@ dashedName: simulate-actions-using-a-headless-browser 請注意,本項目在[這個 Replit 項目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基礎上進行開發。你也可以從 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -在接下來的挑戰中,我們將使用名爲 “Headless Browser(無頭瀏覽器)” 的設備模擬人與頁面的交互。 +在接下來的挑戰中,你將使用無頭瀏覽器模擬人類與頁面的交互。 -無頭瀏覽器是沒有圖形用戶界面的 Web 瀏覽器。 這種工具對於測試網頁特別有用,因爲它能夠以與瀏覽器相同的方式呈現和理解 HTML、CSS 和 JavaScript。 +無頭瀏覽器是沒有 GUI 的 Web 瀏覽器。 它們能夠以與常規瀏覽器相同的方式呈現和解釋 HTML、CSS 和 JavaScript,這使得它們對於測試網頁特別有用。 -針對這些挑戰,我們使用 Zombie.JS。 它是一個輕量級瀏覽器,完全基於 JS,而不需要額外的二進制文件來安裝。 這個特性使我們可以在 Replit 等環境中使用它。 還有許多其他(更強大的)選擇。 +在下面的挑戰中,你將使用Zombie.js,它是一個輕量級的無頭瀏覽器,不依賴額外的二進制文件來安裝。 這一特點使其可以在 Replit 這樣的有限環境中使用。 但是還有許多其他更強大的無頭瀏覽器選項。 -Mocha 允許你在實際測試之前準備一些代碼運行的基礎。 這可能有助於例如在數據庫中創建項目,用於連續測試。 +Mocha 允許你在任何實際測試運行之前運行一些代碼。 這對做一些事情很有用,比如向數據庫添加條目,這些條目將在其餘測試中使用。 -使用無頭瀏覽器,在進行實際測試之前,我們需要**訪問**我們將要檢查的頁面。 `suiteSetup` “hook” 僅在套件啓動時執行。 其他不同的鉤子類型可以在每次測試之前、每次測試之後或者在套件的末尾執行。 更多信息請參閱 Mocha 文檔。 +使用無頭瀏覽器,在運行測試之前,你需要 **訪問** 你要測試的頁面。 + +`suiteSetup` 鉤子僅在測試套件開始時執行一次。 + +還有其他幾種鉤子類型,可以在每次測試前、每次測試後或測試套件結束時執行代碼。 有關更多信息,請參閱 Mocha 文檔。 # --instructions-- -在 `tests/2_functional-tests.js`中,緊接着 `Browser` 聲明之後,將你的項目 URL 添加到變量的 `site` 屬性: +在 `tests/2_functional-tests.js` 中,緊跟在 `Browser` 聲明之後,將你的項目 URL 添加到變量的 `site` 屬性: ```js -Browser.site = 'https://sincere-cone.gomix.me'; // Your URL here +Browser.site = 'https://boilerplate-mochachai.your-username.repl.co'; // Your URL here ``` -如果你在本地環境中測試,則替換上面的代碼爲: - -```js -Browser.localhost('example.com', process.env.PORT || 3000); -``` - -在 `tests/2_functional-tests.js` 中,在 `'Functional Tests with Zombie.js'` 套件的底部,使用以下代碼實例化一個新的 `Browser` 對象: +然後在 `'Functional Tests with Zombie.js'` 套件的根級別,使用以下代碼實例化 `Browser` 對象的新實例: ```js const browser = new Browser(); ``` -然後,通過以下代碼,使用 `suiteSetup` 鉤子把 `browser` 指向 `/` 路由: +並使用 `suiteSetup` 鉤子將 `browser` 定向到帶有以下代碼的 `/` 路由: ```js suiteSetup(function(done) { @@ -53,11 +51,9 @@ suiteSetup(function(done) { ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( (data) => { - data.slice(0, 4).forEach((test) => { - assert.equal(test.state, 'passed'); - }) + assert.equal(data.state, 'passed'); }, (xhr) => { throw new Error(xhr.responseText); diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md index 09ad6c8c5d..02f055a12d 100644 --- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md +++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md @@ -8,27 +8,25 @@ dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-c # --description-- -你可能已经注意到一些 freeCodeCamp JavaScript 的挑战有自己的控制台。 这些控制台的行为与上一次挑战中使用的浏览器控制台略有不同。 +你可能已经注意到一些 freeCodeCamp 的挑战有自己的控制台。 这个控制台的行为与浏览器控制台有些不同。 -以下挑战旨在强调 freeCodeCamp 控制台与浏览器控制台之间的一些差异。 - -当在浏览器中加载并运行 JavaScript 文件时,`console.log()` 语句会在控制台中按照调用的次数准确地打印出要求的内容。 - -在编辑器检测到脚本中的更改之后,以及测试期间,freeCodeCamp 控制台将打印 `console.log()` 语句。 - -在运行测试之前,将清除 freeCodeCamp 控制台,为避免破坏,仅在第一次测试期间打印日志(请参见下面的注释)。 - -如果你想看到每次测试的日志,运行测试,并打开浏览器控制台。 如果你喜欢使用浏览器控制台,想要它模仿 freeCodeCamp 控制台,请在其他 `console` 调用前加上 `console.clear()`,以清除浏览器控制台。 - -**注意:** 每次调用函数时,函数内的 `console.log` 都会被打印到 freeCodeCamp 控制台。 这样可以帮助在测试期间调试函数。 +有许多方法可以与 `console` 一起使用来输出消息。 `log`、`warn` 和 `clear` 就是几个例子。 freeCodeCamp 控制台只会输出 `log` 消息,而浏览器控制台会输出所有消息。 当你对你的代码进行修改时,它将自动运行并显示日志。 每次代码运行时,freeCodeCamp 控制台都会被清除。 # --instructions-- -首先,使用 `console.log` 打印 `output` 变量。 然后使用 `console.clear` 清除浏览器控制台。 +首先,打开浏览器控制台,以便查看日志。 要做到这一点,在大多数浏览器上,你可以右击顶部的 freeCodeCamp 导航栏,并点击 `inspect`。 然后在打开的窗口中找到 `console` 选项卡。 + +之后,使用 `console.log` 记录 `output` 变量。 查看这两个控制台,可以看到日志。 最后,在你的日志后面使用 `console.clear` 清除浏览器控制台。 查看两个控制台的差异。 # --hints-- -应该使用 `console.clear()` 清除浏览器控制台。 +你应该使用 `console.log()` 来打印 `output` 变量。 + +```js +assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +``` + +你应该使用 `console.clear()` 来清除浏览器控制台。 ```js assert( @@ -38,10 +36,14 @@ assert( ); ``` -应该使用 `console.log()` 打印 `output` 变量。 +你应该在你的日志之后清除控制台。 ```js -assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +assert( + __helpers + .removeWhiteSpace(code) + .match(/console\.log\(output\)[\s\S]*console.clear\(\)/) +); ``` # --seed-- @@ -49,25 +51,15 @@ assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); ## --seed-contents-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. ``` # --solutions-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. -console.clear(); +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; + console.log(output); - -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. +console.clear(); ``` diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md index 9779e38bce..a134af48f3 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method.md @@ -10,29 +10,37 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me 请注意,本项目在[这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -接下来,我们将了解如何使用请求的 payload(body)发送数据。 我们需要测试一个 PUT 请求, `'/travellers'` 接收如下的 JSON 对象: +当你测试一个 `PUT` 请求时,你经常会随同它一起发送数据。 你在 `PUT` 请求中包含的数据被称为请求的主体。 + +要将 `PUT` 请求和 JSON 对象发送到 `'/travellers'` 端点,你可以使用 `chai-http` 插件的 `put` 和 `send` 方法: + +```js +chai + .request(server) + .put('/travellers') + .send({ + "surname": [last name of a traveller of the past] + }) + ... +``` + +并且路由响应如下: ```json { - "surname": [last name of a traveller of the past] + "name": [first name], + "surname": [last name], + "dates": [birth - death years] } ``` -路由响应如下: - -```json -{ - "name": [first name], "surname": [last name], "dates": [birth - death years] -} -``` - -更多细节请查看服务器代码。 +请参阅服务器代码以了解对 `'/travellers'` 端点的不同响应。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "Colombo"}'` 测试(`// #3`): +在 `tests/2_functional-tests.js` 中,更改 `'Send {surname: "Colombo"}'` 测试(`// #3`),并使用 `put` 和 `send` 方法来测试 `'/travellers'` 端点。 -发送以下 JSON 响应作为有效载荷: +在你的 PUT 请求中发送以下 JSON 对象。 ```json { @@ -40,14 +48,14 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me } ``` -在 `request.end` 返回中检查以下情况: +在 `request.end` 的返回中检查以下情况: -1. `status` -2. `type` -3. `body.name` -4. `body.surname` +1. `status` 应该是 `200` +2. `type` 应该是 `application/json` +3. `body.name` 应该是 `Cristoforo` +4. `body.surname` 应该是 `Colombo` -请按照以上顺序书写断言,顺序错误会影响系统判定。 完成后,请务必移除 `assert.fail()`。 +请按照以上顺序书写断言,顺序错误会影响系统判定。 此外,请确保在完成后删除 `assert.fail()`。 # --hints-- @@ -65,7 +73,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -应测试 “res.status” 是否为 200。 +应该测试 `res.status` 为 200。 ```js (getUserInput) => @@ -81,7 +89,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要测试 “res.type” 是否为 “application/json”。 +应该测试 `res.type` 是否为 `'application/json'`。 ```js (getUserInput) => @@ -97,7 +105,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要测试 “res.body.name” 是否为 “Cristoforo”。 +你应该测试 `res.body.name` 是否为 `'Cristoforo'`。 ```js (getUserInput) => @@ -113,7 +121,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me ); ``` -需要测试 “res.body.surname” 是否为 “Colombo”。 +你应该测试 `res.body.surname` 是否为 `'Colombo'`。 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md index b105016d28..909d37c71a 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iv---put-method.md @@ -8,15 +8,17 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met # --description-- -请注意,本项目在[这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 这个练习与上一个类似, 我们详细看看。 +请注意,本项目在 [这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) 上克隆。 -你已经看到了它是如何完成的,现在你需要从零开始搭建。 +这个练习与上一个类似。 + +现在你知道如何测试一个 `PUT` 请求了,轮到你从头开始做了。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "da Verrazzano"}'` 测试(`// #4`)。 +在 `tests/2_functional-tests.js` 中,更改 `'Send {surname: "da Verrazzano"}'` 测试(`// #4`)并使用 `put` 和 `send` 方法来测试 `'/travellers'` 端点。 -发送以下 JSON 响应作为有效载荷到 `/travellers` 路径: +在你的 PUT 请求中发送以下 JSON 对象。 ```json { @@ -24,18 +26,18 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met } ``` -在 `request.end` 返回中检查以下情况: +在 `request.end` 的返回中检查以下情况: -1. `status` -2. `type` -3. `body.name` -4. `body.surname` +1. `status` 应该是 `200` +2. `type` 应该是 `application/json` +3. `body.name` 应该是 `Giovanni` +4. `body.surname` 应该是 `da Verrazzano` -请按照以上顺序书写断言,顺序错误会影响系统判定。 完成后请务必删除 `assert.fail()`。 +请按照以上顺序书写断言,顺序错误会影响系统判定。 此外,请确保在完成后删除 `assert.fail()`。 # --hints-- -需要通过所有测试。 +应通过所有测试。 ```js (getUserInput) => @@ -49,7 +51,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要测试 “res.status” 是否为 200。 +应该测试 `res.status` 为 200。 ```js (getUserInput) => @@ -65,7 +67,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要测试 “res.type” 是否为 “application/json”。 +应该测试 `res.type` 是否为 `'application/json'`。 ```js (getUserInput) => @@ -81,7 +83,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要测试 “res.body.name” 为 “Giovanni”。 +应该测试 `res.body.name` 是否为 `'Giovanni'` ```js (getUserInput) => @@ -97,7 +99,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met ); ``` -需要测试 “res.body.surname” 是否为 “da Verrazzano”。 +应该测试 `res.body.surname` 是否为 `'da Verrazzano'` ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md index 3760eb15c4..2c6c67a045 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http-ii.md @@ -12,9 +12,9 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with your name'` 测试(`// #2`),对 `status` 和 `text` 断言。 +在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with your name'` 测试(`// #2`),对响应的 `status` 和 `text` 使用断言来通过测试。 -在查询中发送 name,将 `?name=` 添加到路由。 端点响应 `'hello '`。 +通过将 `?name=` 附加到路由,将你的姓名作为 URL 查询发送。 端点响应 `'hello '`。 # --hints-- @@ -32,7 +32,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii ); ``` -应测试 “res.status” 是否为 200。 +应该测试 `res.status` 为 200 ```js (getUserInput) => @@ -48,7 +48,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii ); ``` -应测试 “res.text“ 是否为 ”hello Guest“。 +应该测试 `res.text` == `'hello '` ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md index 4d041f8091..ecca29592a 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-api-endpoints-using-chai-http.md @@ -10,37 +10,36 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http 请注意,本项目在[这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -Mocha 允许测试异步操作。 有一个差异, 你能发现它吗? +Mocha 允许你使用名为 `chai-http` 的插件测试异步操作,例如调用 API 端点。 -我们可以使用一个叫作 `chai-http` 的插件测试 API 端点。 让我们看看它是如何工作的。 请记住,API 调用是异步的。 - -以下是使用 `chai-http` 测试 `'GET /hello?name=[name] => "hello [name]"'` 套件的例子。 测试通过 `GET` 请求在 url 查询字符串 `?name=John` 中发送一个名称字符串给 `server`。 在 `end` 方法的回调函数中,接收包含 `status` 属性的响应对象(`res`)。 第一个 `assert.equal` 检查状态是否为 `200`。 第二个 `assert.equal` 检查响应字符串 `res.text` 是否为 `"hello John"`。 +以下是使用 `chai-http` 测试名为 `'GET /hello?name=[name] => "hello [name]"'` 的套件的示例: ```js suite('GET /hello?name=[name] => "hello [name]"', function () { - test("?name=John", function (done) { + test('?name=John', function (done) { chai .request(server) - .get("/hello?name=John") + .get('/hello?name=John') .end(function (err, res) { - assert.equal(res.status, 200, "response status should be 200"); - assert.equal( - res.text, - "hello John", - 'response should be "hello John"' - ); + assert.equal(res.status, 200, 'Response status should be 200'); + assert.equal(res.text, 'hello John', 'Response should be "hello John"'); done(); }); }); +}); ``` -请注意测试的回调函数中的 `done` 参数。 在没有传入参数的情况下调用它,是成功完成异步任务所必需的。 +该测试向服务器发送一个 `GET` 请求,并将名称作为 URL 查询字符串(`?name=John`)。 在`end` 方法的回调函数中,接收到响应对象(`res`)并包含 `status` 属性。 + +第一个 `assert.equal` 检查状态是否为 `200`。 第二个 `assert.equal` 检查响应字符串(`res.text`)是否为 `"hello John"`。 + +同时,请注意测试的回调函数中的 `done` 参数。 在测试结束时,调用它且不带参数,是发出异步操作完成所必需的信号。 # --instructions-- -在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with no name'` 测试(`// #1`),对 `status` 和 `text` 使用断言。 不要修改传给断言的参数。 +在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with no name'` 测试(`// #1`),对响应的 `status` 和 `text` 使用断言来通过测试。 不要改变传递给断言的参数。 -不要在 query 中传入 name,端点将会返回 `hello Guest`。 +不应该有任何 URL 查询。 如果没有名称 URL 查询,端点将使用 `hello Guest` 进行响应。 # --hints-- @@ -58,7 +57,7 @@ suite('GET /hello?name=[name] => "hello [name]"', function () { ); ``` -应测试 “res.status” 是否为 200。 +应该测试 `res.status` 为 200。 ```js (getUserInput) => @@ -74,7 +73,7 @@ suite('GET /hello?name=[name] => "hello [name]"', function () { ); ``` -应测试 “res.text“ 是否为 ”hello Guest“。 +应该测试 `res.text` == `'hello Guest'`。 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md index d77829fbc8..46882574df 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser-ii.md @@ -12,17 +12,17 @@ dashedName: run-functional-tests-using-a-headless-browser-ii # --instructions-- -在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Vespucci" - write your e2e test...'` 测试(`// #6`),自动化填写和提交表单: +在 `tests/2_functional-tests.js` 中,在 `'Submit the surname "Vespucci" in the HTML form'` 测试(`// #5`),自动执行以下操作: -1. 在表单中填写 `Vespucci` 的 `surname`。 -2. 点击 `'submit'` 按钮提交表单 +1. 在表格中填写姓氏 `Vespucci`。 +2. 点击提交按钮 -在回调中: +在 `pressButton` 回调中: -1. 断言状态是正常的 `200` -2. 断言元素 `span#name` 中的文本是 `'Amerigo'` -3. 断言元素 `span#surname` 元素中的文本是 `'Vespucci'` -4. 断言有 `span#dates` 元素,它们的计数是 `1` +1. 断言状态是正常的 `200`。 +2. 断言元素 `span#name` 中的文本是 `'Amerigo'`。 +3. 断言元素 `span#surname` 元素中的文本是 `'Vespucci'`。 +4. 断言有 `span#dates` 元素,它们的计数是 `1`。 不要忘记删除 `assert.fail()` 调用。 @@ -32,7 +32,7 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.state, 'passed'); }, @@ -46,7 +46,7 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[0].method, 'browser.success'); }, @@ -56,11 +56,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -应断言元素 “span#surname” 中的文本为 “Vespucci”。 +应断言元素 `span#name` 中的文本是 `'Amerigo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[1].method, 'browser.text'); assert.match(data.assertions[1].args[0], /('|")span#name\1/); @@ -72,11 +72,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -应断言元素 “span#surname” 中的文本为 “Vespucci”。 +应断言元素 `span#surname` 中的文本是 `'Vespucci'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[2].method, 'browser.text'); assert.match(data.assertions[2].args[0], /('|")span#surname\1/); @@ -88,11 +88,11 @@ dashedName: run-functional-tests-using-a-headless-browser-ii ); ``` -应该断言元素 “span#dates” 存在,且它的值为 1。 +应该断言元素 `span#dates` 存在,且它的值为 1。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then( (data) => { assert.equal(data.assertions[3].method, 'browser.elements'); assert.match(data.assertions[3].args[0], /('|")span#dates\1/); diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md index bab07cedff..3a0da4d635 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser.md @@ -10,23 +10,31 @@ dashedName: run-functional-tests-using-a-headless-browser 请注意,本项目在[这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -在 HTML 主视图中有一个输入表格。 它发送数据到 `PUT /travellers` 端点,我们在上面的 Ajax 请求中使用。 当请求成功完成时,客户端代码会给 DOM 增加一个包含调用返回信息的 `
`。 下面的例子展示了如何使用这个表格: +在页面上有一个输入表单。 它将数据作为 AJAX 请求发送到 `PUT /travellers` 端点。 + +当请求成功完成后,客户端代码将一个包含响应信息的 `
` 附加到 DOM 中。 + +下面是一个如何使用 Zombie.js 与表单互动的例子。 ```js -test('#test - submit the input "surname" : "Polo"', function (done) { - browser.fill('surname', 'Polo').pressButton('submit', function () { - browser.assert.success(); - browser.assert.text('span#name', 'Marco'); - browser.assert.text('span#surname', 'Polo'); - browser.assert.elements('span#dates', 1); - done(); +test('Submit the surname "Polo" in the HTML form', function (done) { + browser.fill('surname', 'Polo').then(() => { + browser.pressButton('submit', () => { + browser.assert.success(); + browser.assert.text('span#name', 'Marco'); + browser.assert.text('span#surname', 'Polo'); + browser.assert.elements('span#dates', 1); + done(); + }); }); -} +}); ``` -首先, `browser` 对象的 `fill` 方法在表格的 `surname` 字段中填入值 `'Polo'`。 紧接着,`pressButton` 方法调用表单的 `submit` 事件监听器。 `pressButton` 方法是异步的。 +首先, `browser` 对象的 `fill` 方法在表格的 `surname` 字段中填入值 `'Polo'`。 `fill` 返回一个 promise,所以 `then` 被链接起来。 -收到 AJAX 请求的响应之后,会有几项断言确认: +在 `then` 回调中,`browser` 对象的 `pressButton` 方法用于调用表单的 `submit` 的事件侦听器。 `pressButton` 方法是异步的。 + +然后,一旦收到来自 AJAX 请求的响应,就会做出一些断言来确认: 1. 响应状态是 `200` 2. `` 元素的文本是 `'Marco'` @@ -37,17 +45,17 @@ test('#test - submit the input "surname" : "Polo"', function (done) { # --instructions-- -在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Colombo" - write your e2e test...'` 测试(`// #5`),自动化填入和提交表单: +在 `tests/2_functional-tests.js` 中,在 `'Submit the surname "Colombo" in the HTML form'` 测试(`// #5`),自动执行以下操作: -1. 填写表单 -2. 点击 `'submit'` 按钮提交表单 +1. 在表格中填写姓氏 `Colombo`。 +2. 点击提交按钮 -在回调中: +在 `pressButton` 回调中: -1. 断言状态是正常的 `200` -2. 断言元素 `span#name` 中的文本是 `'Cristoforo'` -3. 断言元素 `span#surname` 元素中的文本是 `'Colombo'` -4. 断言有 `span#dates` 元素,它们的计数是 `1` +1. 断言状态是正常的 `200`。 +2. 断言元素 `span#name` 中的文本是 `'Cristoforo'`。 +3. 断言元素 `span#surname` 中的文本是 `'Colombo'`。 +4. 断言有 `span#dates` 元素,它们的计数是 `1`。 不要忘记删除 `assert.fail()` 调用。 @@ -57,7 +65,7 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.state, 'passed'); }, @@ -67,11 +75,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -应该断言无头浏览器请求成功。 +应断言无头浏览器成功执行请求。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[0].method, 'browser.success'); }, @@ -81,11 +89,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -应该断言元素 “span#name” 中的文字为 “Cristoforo”。 +应断言元素 `span#name` 中的文本是 `'Cristoforo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[1].method, 'browser.text'); assert.match(data.assertions[1].args[0], /('|")span#name\1/); @@ -97,11 +105,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -应该断言元素 “span#surname” 中的文字为 “Colombo”。 +应断言元素 `span#surname` 中的文本是 `'Colombo'`。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[2].method, 'browser.text'); assert.match(data.assertions[2].args[0], /('|")span#surname\1/); @@ -113,11 +121,11 @@ test('#test - submit the input "surname" : "Polo"', function (done) { ); ``` -应该断言元素 “span#dates” 存在,且它的值为 1。 +应该断言元素 `span#dates` 存在,且它的值为 1。 ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then( (data) => { assert.equal(data.assertions[3].method, 'browser.elements'); assert.match(data.assertions[3].args[0], /('|")span#dates\1/); diff --git a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md index 98abb0c258..664e0e2762 100644 --- a/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md +++ b/curriculum/challenges/chinese/06-quality-assurance/quality-assurance-and-testing-with-chai/simulate-actions-using-a-headless-browser.md @@ -9,37 +9,35 @@ dashedName: simulate-actions-using-a-headless-browser 请注意,本项目在[这个 Replit 项目](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 -在接下来的挑战中,我们将使用名为 “Headless Browser(无头浏览器)” 的设备模拟人与页面的交互。 +在接下来的挑战中,你将使用无头浏览器模拟人类与页面的交互。 -无头浏览器是没有图形用户界面的 Web 浏览器。 这种工具对于测试网页特别有用,因为它能够以与浏览器相同的方式呈现和理解 HTML、CSS 和 JavaScript。 +无头浏览器是没有 GUI 的 Web 浏览器。 它们能够以与常规浏览器相同的方式呈现和解释 HTML、CSS 和 JavaScript,这使得它们对于测试网页特别有用。 -针对这些挑战,我们使用 Zombie.JS。 它是一个轻量级浏览器,完全基于 JS,而不需要额外的二进制文件来安装。 这个特性使我们可以在 Replit 等环境中使用它。 还有许多其他(更强大的)选择。 +在下面的挑战中,你将使用Zombie.js,它是一个轻量级的无头浏览器,不依赖额外的二进制文件来安装。 这一特点使其可以在 Replit 这样的有限环境中使用。 但是还有许多其他更强大的无头浏览器选项。 -Mocha 允许你在实际测试之前准备一些代码运行的基础。 这可能有助于例如在数据库中创建项目,用于连续测试。 +Mocha 允许你在任何实际测试运行之前运行一些代码。 这对做一些事情很有用,比如向数据库添加条目,这些条目将在其余测试中使用。 -使用无头浏览器,在进行实际测试之前,我们需要**访问**我们将要检查的页面。 `suiteSetup` “hook” 仅在套件启动时执行。 其他不同的钩子类型可以在每次测试之前、每次测试之后或者在套件的末尾执行。 更多信息请参阅 Mocha 文档。 +使用无头浏览器,在运行测试之前,你需要 **访问** 你要测试的页面。 + +`suiteSetup` 钩子仅在测试套件开始时执行一次。 + +还有其他几种钩子类型,可以在每次测试前、每次测试后或测试套件结束时执行代码。 有关更多信息,请参阅 Mocha 文档。 # --instructions-- -在 `tests/2_functional-tests.js`中,紧接着 `Browser` 声明之后,将你的项目 URL 添加到变量的 `site` 属性: +在 `tests/2_functional-tests.js` 中,紧跟在 `Browser` 声明之后,将你的项目 URL 添加到变量的 `site` 属性: ```js -Browser.site = 'https://sincere-cone.gomix.me'; // Your URL here +Browser.site = 'https://boilerplate-mochachai.your-username.repl.co'; // Your URL here ``` -如果你在本地环境中测试,则替换上面的代码为: - -```js -Browser.localhost('example.com', process.env.PORT || 3000); -``` - -在 `tests/2_functional-tests.js` 中,在 `'Functional Tests with Zombie.js'` 套件的底部,使用以下代码实例化一个新的 `Browser` 对象: +然后在 `'Functional Tests with Zombie.js'` 套件的根级别,使用以下代码实例化 `Browser` 对象的新实例: ```js const browser = new Browser(); ``` -然后,通过以下代码,使用 `suiteSetup` 钩子把 `browser` 指向 `/` 路由: +并使用 `suiteSetup` 钩子将 `browser` 定向到带有以下代码的 `/` 路由: ```js suiteSetup(function(done) { @@ -53,11 +51,9 @@ suiteSetup(function(done) { ```js (getUserInput) => - $.get(getUserInput('url') + '/_api/get-tests?type=functional').then( + $.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then( (data) => { - data.slice(0, 4).forEach((test) => { - assert.equal(test.state, 'passed'); - }) + assert.equal(data.state, 'passed'); }, (xhr) => { throw new Error(xhr.responseText); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-276-primitive-triangles.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-276-primitive-triangles.md index 0e8392e57b..260f8c73a0 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-276-primitive-triangles.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-276-primitive-triangles.md @@ -1,6 +1,6 @@ --- id: 5900f4801000cf542c50ff93 -title: 'Problem 276: Primitive Triangles' +title: 'Problema 276: Triângulos primitivos' challengeType: 5 forumTopicId: 301926 dashedName: problem-276-primitive-triangles @@ -8,18 +8,18 @@ dashedName: problem-276-primitive-triangles # --description-- -Consider the triangles with integer sides a, b and c with a ≤ b ≤ c. +Considere os triângulos com os lados inteiros $a$, $b$ e $c$ com $a ≤ b ≤ c$. -An integer sided triangle (a,b,c) is called primitive if gcd(a,b,c)=1. +Um triângulo que tem seus lados sendo números inteiros $(a,b,c)$ é chamado primitivo se $gcd(a,b,c) = 1$. -How many primitive integer sided triangles exist with a perimeter not exceeding 10 000 000? +Quantos triângulos primitivos (com os lados sendo números inteiros) existem com um perímetro que não excede $10\\,000\\,000$? # --hints-- -`euler276()` should return 5777137137739633000. +`primitiveTriangles()` deve retornar `5777137137739633000`. ```js -assert.strictEqual(euler276(), 5777137137739633000); +assert.strictEqual(primitiveTriangles(), 5777137137739633000); ``` # --seed-- @@ -27,12 +27,12 @@ assert.strictEqual(euler276(), 5777137137739633000); ## --seed-contents-- ```js -function euler276() { +function primitiveTriangles() { return true; } -euler276(); +primitiveTriangles(); ``` # --solutions-- diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.md index 8989f4171c..622a9d80a6 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.md @@ -1,6 +1,6 @@ --- id: 5900f3a91000cf542c50febc -title: 'Problem 61: Cyclical figurate numbers' +title: 'Problema 61: Números cíclicos' challengeType: 5 forumTopicId: 302173 dashedName: problem-61-cyclical-figurate-numbers @@ -8,52 +8,52 @@ dashedName: problem-61-cyclical-figurate-numbers # --description-- -Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae: +Números triângulares, quadrado, pentagonais, hexagonais, heptagonais e octogonal são números figurativos (poligonais) e são gerados pelas seguintes fórmulas: -| Type of Number | Formula | Sequence | +| Tipo de número | Fórmula | Sequência | | -------------- | ----------------------------- | --------------------- | -| Triangle | $P_3(n) = \frac{n(n+1)}{2}$ | 1, 3, 6, 10, 15, ... | -| Square | $P_4(n) = n^2$ | 1, 4, 9, 16, 25, ... | +| Triangular | $P_3(n) = \frac{n(n+1)}{2}$ | 1, 3, 6, 10, 15, ... | +| Quadrado | $P_4(n) = n^2$ | 1, 4, 9, 16, 25, ... | | Pentagonal | $P_5(n) = \frac{n(3n−1)}2$ | 1, 5, 12, 22, 35, ... | | Hexagonal | $P_6(n) = n(2n−1)$ | 1, 6, 15, 28, 45, ... | | Heptagonal | $P_7(n) = \frac{n(5n−3)}{2}$ | 1, 7, 18, 34, 55, ... | | Octagonal | $P_8(n) = n(3n−2)$ | 1, 8, 21, 40, 65, ... | -The ordered set of three 4-digit numbers: 8128, 2882, 8281, has three interesting properties. +O conjunto ordenado de três números que possuem 4 algarismos, 8128, 2882, 8281, possui três propriedades interessantes. -1. The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first). -2. Each polygonal type: triangle ($P_3(127) = 8128$), square ($P_4(91) = 8281$), and pentagonal ($P_5(44) = 2882$), is represented by a different number in the set. -3. This is the only set of 4-digit numbers with this property. +1. O conjunto é cíclico. Podemos notar que os dois últimos dígitos de cada número são os dois primeiros dígitos do próximo número (incluindo o último número com o primeiro). +2. Cada tipo poligonal, triângulo ($P_3(127) = 8128$), quadrado ($P_4(91) = 8281$) e pentagonal ($P_5(44) = 2882$), é representado por um número diferente no conjunto. +3. Este é o único conjunto de números de 4 algarismos com estas propriedades. -Find the sum of all numbers in ordered sets of `n` cyclic 4-digit numbers for which each of the $P_3$ to $P_{n + 2}$ polygonal types, is represented by a different number in the set. +Calcule a soma de todos os números em conjuntos ordenados de `n` números de 4 algarismos cíclicos, onde cada tipo poligonal de $P_3$ a $P_{n + 2}$ é representado por um número diferente no conjunto. # --hints-- -`cyclicalFigurateNums(3)` should return a number. +`cyclicalFigurateNums(3)` deve retornar um número. ```js assert(typeof cyclicalFigurateNums(3) === 'number'); ``` -`cyclicalFigurateNums(3)` should return `19291`. +`cyclicalFigurateNums(3)` deve retornar `19291`. ```js assert.strictEqual(cyclicalFigurateNums(3), 19291); ``` -`cyclicalFigurateNums(4)` should return `28684`. +`cyclicalFigurateNums(4)` deve retornar `28684`. ```js assert.strictEqual(cyclicalFigurateNums(4), 28684); ``` -`cyclicalFigurateNums(5)` should return `76255`. +`cyclicalFigurateNums(5)` deve retornar `76255`. ```js assert.strictEqual(cyclicalFigurateNums(5), 76255); ``` -`cyclicalFigurateNums(6)` should return `28684`. +`cyclicalFigurateNums(6)` deve retornar `28684`. ```js assert.strictEqual(cyclicalFigurateNums(6), 28684); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-62-cubic-permutations.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-62-cubic-permutations.md index 82294e0708..fb0b343a09 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-62-cubic-permutations.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-62-cubic-permutations.md @@ -1,6 +1,6 @@ --- id: 5900f3aa1000cf542c50febd -title: 'Problem 62: Cubic permutations' +title: 'Problema 62: Permutações cúbicas' challengeType: 5 forumTopicId: 302174 dashedName: problem-62-cubic-permutations @@ -8,37 +8,37 @@ dashedName: problem-62-cubic-permutations # --description-- -The cube, 41063625 ($345^3$), can be permuted to produce two other cubes: 56623104 ($384^3$) and 66430125 ($405^3$). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. +O número 41063625 é o resultado do cubo ($345^3$). Esse número pode ser permutado para produzir dois outros números que também são resultados de um cubo: 56623104 ($384^3$) e 66430125 ($405^3$). 41063625 é o menor número que tem exatamente três permutações dos seus dígitos e essas permutações também são o resultado de um cubo. -Find the smallest cube for which exactly `n` permutations of its digits are cube. +Encontre o menor cubo onde `n` permutações de seus dígitos são cubos. # --hints-- -`cubicPermutations(2)` should return a number. +`cubicPermutations(2)` deve retornar um número. ```js assert(typeof cubicPermutations(2) === 'number'); ``` -`cubicPermutations(2)` should return `125`. +`cubicPermutations(2)` deve retornar `125`. ```js assert.strictEqual(cubicPermutations(2), 125); ``` -`cubicPermutations(3)` should return `41063625`. +`cubicPermutations(3)` deve retornar `41063625`. ```js assert.strictEqual(cubicPermutations(3), 41063625); ``` -`cubicPermutations(4)` should return `1006012008`. +`cubicPermutations(4)` deve retornar `1006012008`. ```js assert.strictEqual(cubicPermutations(4), 1006012008); ``` -`cubicPermutations(5)` should return `127035954683`. +`cubicPermutations(5)` deve retornar `127035954683`. ```js assert.strictEqual(cubicPermutations(5), 127035954683); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-63-powerful-digit-counts.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-63-powerful-digit-counts.md index 02c9603685..407ed1e2ae 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-63-powerful-digit-counts.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-63-powerful-digit-counts.md @@ -1,6 +1,6 @@ --- id: 5900f3ab1000cf542c50febe -title: 'Problem 63: Powerful digit counts' +title: 'Problema 63: Contagem poderosa de dígitos' challengeType: 5 forumTopicId: 302175 dashedName: problem-63-powerful-digit-counts @@ -8,73 +8,73 @@ dashedName: problem-63-powerful-digit-counts # --description-- -The 5-digit number, 16807 = 75, is also a fifth power. Similarly, the 9-digit number, 134217728 = 89, is a ninth power. +O número de 5 algarismos, 16807 = 75, também é uma quinta potência. Da mesma forma, o número de 9 algarismos, 134217728 = 89, é uma nona potência. -Complete the function so that it returns how many positive integers are of length `n` and an `n`th power. +Complete a função para que ela retorne quantos números inteiros e positivos são da `n`-ésima potência e de comprimento `n`. # --hints-- -`powerfulDigitCounts(1)` should return a number. +`powerfulDigitCounts(1)` deve retornar um número. ```js assert(typeof powerfulDigitCounts(1) === 'number'); ``` -`powerfulDigitCounts(1)` should return `9`. +`powerfulDigitCounts(1)` deve retornar `9`. ```js assert.strictEqual(powerfulDigitCounts(1), 9); ``` -`powerfulDigitCounts(2)` should return `6`. +`powerfulDigitCounts(2)` deve retornar `6`. ```js assert.strictEqual(powerfulDigitCounts(2), 6); ``` -`powerfulDigitCounts(3)` should return `5`. +`powerfulDigitCounts(3)` deve retornar `5`. ```js assert.strictEqual(powerfulDigitCounts(3), 5); ``` -`powerfulDigitCounts(4)` should return `4`. +`powerfulDigitCounts(4)` deve retornar `4`. ```js assert.strictEqual(powerfulDigitCounts(4), 4); ``` -`powerfulDigitCounts(5)` should return `3`. +`powerfulDigitCounts(5)` deve retornar `3`. ```js assert.strictEqual(powerfulDigitCounts(5), 3); ``` -`powerfulDigitCounts(6)` should return `3`. +`powerfulDigitCounts(6)` deve retornar `3`. ```js assert.strictEqual(powerfulDigitCounts(6), 3); ``` -`powerfulDigitCounts(7)` should return `2`. +`powerfulDigitCounts(7)` deve retornar `2`. ```js assert.strictEqual(powerfulDigitCounts(7), 2); ``` -`powerfulDigitCounts(8)` should return `2`. +`powerfulDigitCounts(8)` deve retornar `2`. ```js assert.strictEqual(powerfulDigitCounts(8), 2); ``` -`powerfulDigitCounts(10)` should return `2`. +`powerfulDigitCounts(10)` deve retornar `2`. ```js assert.strictEqual(powerfulDigitCounts(10), 2); ``` -`powerfulDigitCounts(21)` should return `1`. +`powerfulDigitCounts(21)` deve retornar `1`. ```js assert.strictEqual(powerfulDigitCounts(21), 1); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-64-odd-period-square-roots.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-64-odd-period-square-roots.md index 6cc017e1fb..08c1cf59df 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-64-odd-period-square-roots.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-64-odd-period-square-roots.md @@ -1,6 +1,6 @@ --- id: 5900f3ac1000cf542c50febf -title: 'Problem 64: Odd period square roots' +title: 'Problema 64: Repetições ímpar da raiz quadrada' challengeType: 5 forumTopicId: 302176 dashedName: problem-64-odd-period-square-roots @@ -8,19 +8,19 @@ dashedName: problem-64-odd-period-square-roots # --description-- -All square roots are periodic when written as continued fractions and can be written in the form: +Todas as raízes quadradas são periódicas quando escritas como frações contínuas e podem ser escritas na forma: $\\displaystyle \\quad \\quad \\sqrt{N}=a_0+\\frac 1 {a_1+\\frac 1 {a_2+ \\frac 1 {a3+ \\dots}}}$ -For example, let us consider $\\sqrt{23}:$: +Por exemplo, consideremos $\\sqrt{23}:$: $\\quad \\quad \\sqrt{23}=4+\\sqrt{23}-4=4+\\frac 1 {\\frac 1 {\\sqrt{23}-4}}=4+\\frac 1 {1+\\frac{\\sqrt{23}-3}7}$ -If we continue we would get the following expansion: +Se continuarmos, teremos a seguinte expansão: $\\displaystyle \\quad \\quad \\sqrt{23}=4+\\frac 1 {1+\\frac 1 {3+ \\frac 1 {1+\\frac 1 {8+ \\dots}}}}$ -The process can be summarized as follows: +O processo pode ser resumido da seguinte forma: $\\quad \\quad a_0=4, \\frac 1 {\\sqrt{23}-4}=\\frac {\\sqrt{23}+4} 7=1+\\frac {\\sqrt{23}-3} 7$ @@ -38,61 +38,61 @@ $\\quad \\quad a_6=3, \\frac 2 {\\sqrt{23}-3}=\\frac {2(\\sqrt{23}+3)} {14}=1+\\ $\\quad \\quad a_7=1, \\frac 7 {\\sqrt{23}-4}=\\frac {7(\\sqrt{23}+4)} {7}=8+\\sqrt{23}-4$ -It can be seen that the sequence is repeating. For conciseness, we use the notation $\\sqrt{23}=\[4;(1,3,1,8)]$, to indicate that the block (1,3,1,8) repeats indefinitely. +Podemos ver que a sequência está se repetindo. Para sermos concisos, podemos usar a notação $\\sqrt{23}=\[4;(1,3,1,8)]$ para indicar que o bloco (1, 3, 1, 8) se repete indefinidamente. -The first ten continued fraction representations of (irrational) square roots are: +As primeiras dez representações de raízes (irracionais) contínuas são: -$\\quad \\quad \\sqrt{2}=\[1;(2)]$, period = 1 +$\\quad \\quad \\sqrt{2}=\[1;(2)]$, repetições = 1 -$\\quad \\quad \\sqrt{3}=\[1;(1,2)]$, period = 2 +$\\quad \\quad \\sqrt{3}=\[1;(1,2)]$, repetições = 2 -$\\quad \\quad \\sqrt{5}=\[2;(4)]$, period = 1 +$\\quad \\quad \\sqrt{5}=\[2;(4)]$, repetições = 1 -$\\quad \\quad \\sqrt{6}=\[2;(2,4)]$, period = 2 +$\\quad \\quad \\sqrt{6}=\[2;(2,4)]$, repetições = 2 -$\\quad \\quad \\sqrt{7}=\[2;(1,1,1,4)]$, period = 4 +$\\quad \\quad \\sqrt{7}=\[2;(1,1,1,4)]$, repetições = 4 -$\\quad \\quad \\sqrt{8}=\[2;(1,4)]$, period = 2 +$\\quad \\quad \\sqrt{8}=\[2;(1,4)]$, repetições = 2 -$\\quad \\quad \\sqrt{10}=\[3;(6)]$, period = 1 +$\\quad \\quad \\sqrt{10}=\[3;(6)]$, repetições = 1 -$\\quad \\quad \\sqrt{11}=\[3;(3,6)]$, period = 2 +$\\quad \\quad \\sqrt{11}=\[3;(3,6)]$, repetições = 2 -$\\quad \\quad \\sqrt{12}=\[3;(2,6)]$, period = 2 +$\\quad \\quad \\sqrt{12}=\[3;(2,6)]$, repetições = 2 -$\\quad \\quad \\sqrt{13}=\[3;(1,1,1,1,6)]$, period = 5 +$\\quad \\quad \\sqrt{13}=\[3;(1,1,1,1,6)]$, repetições = 5 -Exactly four continued fractions, for $N \\le 13$, have an odd period. +Exatamente quatro frações contínuas, onde $N \\le 13$, têm um total de repetições ímpar. -How many continued fractions for $N \\le n$ have an odd period? +Quantas frações contínuas onde $N \\le n$ têm repetições ímpar? # --hints-- -`oddPeriodSqrts(13)` should return a number. +`oddPeriodSqrts(13)` deve retornar um número. ```js assert(typeof oddPeriodSqrts(13) === 'number'); ``` -`oddPeriodSqrts(500)` should return `83`. +`oddPeriodSqrts(500)` deve retornar `83`. ```js assert.strictEqual(oddPeriodSqrts(500), 83); ``` -`oddPeriodSqrts(1000)` should return `152`. +`oddPeriodSqrts(1000)` deve retornar `152`. ```js assert.strictEqual(oddPeriodSqrts(1000), 152); ``` -`oddPeriodSqrts(5000)` should return `690`. +`oddPeriodSqrts(5000)` deve retornar `690`. ```js assert.strictEqual(oddPeriodSqrts(5000), 690); ``` -`oddPeriodSqrts(10000)` should return `1322`. +`oddPeriodSqrts(10000)` deve retornar `1322`. ```js assert.strictEqual(oddPeriodSqrts(10000), 1322); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-65-convergents-of-e.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-65-convergents-of-e.md index 7a1383a7f0..0068779712 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-65-convergents-of-e.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-65-convergents-of-e.md @@ -1,6 +1,6 @@ --- id: 5900f3ad1000cf542c50fec0 -title: 'Problem 65: Convergents of e' +title: 'Problema 65: Convergentes de e' challengeType: 5 forumTopicId: 302177 dashedName: problem-65-convergents-of-e @@ -8,59 +8,59 @@ dashedName: problem-65-convergents-of-e # --description-- -The square root of 2 can be written as an infinite continued fraction. +A raiz quadrada de 2 pode ser escrita como uma fração contínua e infinita. $\\sqrt{2} = 1 + \\dfrac{1}{2 + \\dfrac{1}{2 + \\dfrac{1}{2 + \\dfrac{1}{2 + ...}}}}$ -The infinite continued fraction can be written, $\\sqrt{2} = \[1; (2)]$ indicates that 2 repeats *ad infinitum*. In a similar way, $\\sqrt{23} = \[4; (1, 3, 1, 8)]$. It turns out that the sequence of partial values of continued fractions for square roots provide the best rational approximations. Let us consider the convergents for $\\sqrt{2}$. +Uma fração contínua e infinita pode ser representada por $\\sqrt{2} = \[1; (2)]$. Essa representação indica que 2 se repete *ad infinitum*. Da mesma forma, $\\sqrt{23} = \[4; (1, 3, 1, 8)]$. Acontece que a sequência de valores parciais de frações contínuas de raízes quadradas fornece as melhores aproximações racionais. Considere as convergências de $\\sqrt{2}$. $1 + \\dfrac{1}{2} = \\dfrac{3}{2}\\\\ 1 + \\dfrac{1}{2 + \\dfrac{1}{2}} = \\dfrac{7}{5}\\\\ 1 + \\dfrac{1}{2 + \\dfrac{1}{2 + \\dfrac{1}{2}}} = \\dfrac{17}{12}\\\\ 1 + \\dfrac{1}{2 + \\dfrac{1}{2 + \\dfrac{1}{2 + \\dfrac{1}{2}}}} = \\dfrac{41}{29}$ -Hence the sequence of the first ten convergents for $\\sqrt{2}$ are: +Assim, a sequência dos primeiros dez convergentes onde $\\sqrt{2}$ são: $1, \\dfrac{3}{2}, \\dfrac{7}{5}, \\dfrac{17}{12}, \\dfrac{41}{29}, \\dfrac{99}{70}, \\dfrac{239}{169}, \\dfrac{577}{408}, \\dfrac{1393}{985}, \\dfrac{3363}{2378}, ...$ -What is most surprising is that the important mathematical constant, $e = \[2; 1, 2, 1, 1, 4, 1, 1, 6, 1, ... , 1, 2k, 1, ...]$. The first ten terms in the sequence of convergents for `e` are: +O que é mais surpreendente é a constante matemática, $e = \[2; 1, 2, 1, 1, 4, 1, 1, 6, 1, ... , 1, 2k, 1, ...]$. Os primeiros dez termos na sequência de convergentes para `e` são: $2, 3, \\dfrac{8}{3}, \\dfrac{11}{4}, \\dfrac{19}{7}, \\dfrac{87}{32}, \\dfrac{106}{39}, \\dfrac{193}{71}, \\dfrac{1264}{465}, \\dfrac{1457}{536}, ...$ -The sum of digits in the numerator of the 10th convergent is $1 + 4 + 5 + 7 = 17$. +A soma de algarismos no numerador do 10o convergente é $1 + 4 + 5 + 7 = 17$. -Find the sum of digits in the numerator of the `n`th convergent of the continued fraction for `e`. +Calcule a soma dos dígitos no numerador do `n`o convergente da fração contínua para `e`. # --hints-- -`convergentsOfE(10)` should return a number. +`convergentsOfE(10)` deve retornar um número. ```js assert(typeof convergentsOfE(10) === 'number'); ``` -`convergentsOfE(10)` should return `17`. +`convergentsOfE(10)` deve retornar `17`. ```js assert.strictEqual(convergentsOfE(10), 17); ``` -`convergentsOfE(30)` should return `53`. +`convergentsOfE(30)` deve retornar `53`. ```js assert.strictEqual(convergentsOfE(30), 53); ``` -`convergentsOfE(50)` should return `91`. +`convergentsOfE(50)` deve retornar `91`. ```js assert.strictEqual(convergentsOfE(50), 91); ``` -`convergentsOfE(70)` should return `169`. +`convergentsOfE(70)` deve retornar `169`. ```js assert.strictEqual(convergentsOfE(70), 169); ``` -`convergentsOfE(100)` should return `272`. +`convergentsOfE(100)` deve retornar `272`. ```js assert.strictEqual(convergentsOfE(100), 272); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-66-diophantine-equation.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-66-diophantine-equation.md index 0eab98070b..db3a0c7bf3 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-66-diophantine-equation.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-66-diophantine-equation.md @@ -1,6 +1,6 @@ --- id: 5900f3ae1000cf542c50fec1 -title: 'Problem 66: Diophantine equation' +title: 'Problema 66: Equação Diofantina' challengeType: 5 forumTopicId: 302178 dashedName: problem-66-diophantine-equation @@ -8,15 +8,15 @@ dashedName: problem-66-diophantine-equation # --description-- -Consider quadratic Diophantine equations of the form: +Considere a fórmula da equação Diofantina:
x2 – Dy2 = 1
-For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1. +Por exemplo, quando D = 13, a solução mínima de x é 6492 - 13×1802 = 1. -It can be assumed that there are no solutions in positive integers when D is square. +Podemos partir do princípio de que não há soluções para números inteiros positivos quando D é o resultado de um número elevado ao quadrado. -By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the following: +Ao encontrar soluções mínimas de x onde D = {2, 3, 5, 6, 7}, obtemos o seguinte:
32 – 2×22 = 1
@@ -26,43 +26,43 @@ By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the followi 82 – 7×32 = 1
-Hence, by considering minimal solutions in `x` for D ≤ 7, the largest `x` is obtained when D=5. +Portanto, considerando soluções mínimas de `x` onde D ≤ 7, o maior `x` é obtido quando D = 5. -Find the value of D ≤ `n` in minimal solutions of `x` for which the largest value of `x` is obtained. +Calcule o valor de D ≤ `n` em soluções mínimas de `x` para as quais o maior valor de `x` é obtido. # --hints-- -`diophantineEquation(7)` should return a number. +`diophantineEquation(7)` deve retornar um número. ```js assert(typeof diophantineEquation(7) === 'number'); ``` -`diophantineEquation(7)` should return `5`. +`diophantineEquation(7)` deve retornar `5`. ``` assert.strictEqual(diophantineEquation(7), 5); ``` -`diophantineEquation(100)` should return `61`. +`diophantineEquation(100)` deve retornar `61`. ``` assert.strictEqual(diophantineEquation(100), 61); ``` -`diophantineEquation(409)` should return `409`. +`diophantineEquation(409)` deve retornar `409`. ``` assert.strictEqual(diophantineEquation(409), 409); ``` -`diophantineEquation(500)` should return `421`. +`diophantineEquation(500)` deve retornar `421`. ``` assert.strictEqual(diophantineEquation(500), 421); ``` -`diophantineEquation(1000)` should return `661`. +`diophantineEquation(1000)` deve retornar `661`. ```js assert.strictEqual(diophantineEquation(1000), 661); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-67-maximum-path-sum-ii.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-67-maximum-path-sum-ii.md index 9e1e818c9c..73153ac940 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-67-maximum-path-sum-ii.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-67-maximum-path-sum-ii.md @@ -1,6 +1,6 @@ --- id: 5900f3b01000cf542c50fec2 -title: 'Problem 67: Maximum path sum II' +title: 'Problema 67: Soma do caminho máximo II' challengeType: 5 forumTopicId: 302179 dashedName: problem-67-maximum-path-sum-ii @@ -8,7 +8,7 @@ dashedName: problem-67-maximum-path-sum-ii # --description-- -By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. +Começando no topo do triângulo abaixo e movendo-se para os números adjacentes na linha abaixo, o total máximo de cima para baixo é 23.
3
@@ -17,27 +17,27 @@ By starting at the top of the triangle below and moving to adjacent numbers on t 8 5 9 3
-That is, 3 + 7 + 4 + 9 = 23. +Ou seja, 3 + 7 + 4 + 9 = 23. -Find the maximum total from top to bottom in `numTriangle`, a 2D array defined in the background containing a triangle with one-hundred rows. +Calcule o total máximo de cima para baixo em `numTriangle`, um array 2D definido em segundo plano contendo um triângulo com cem linhas. -**Note:** This is a much more difficult version of Problem 18. It is not possible to try every route to solve this problem, as there are 299 altogether! If you could check one trillion (1012) routes every second it would take over twenty billion years to check them all. There is an efficient algorithm to solve it. ;o) +**Observação:** esta é uma versão muito mais difícil do Problema 18. Não é possível tentar todas as rotas para resolver este problema, pois há 299 rotas no total! Se você pudesse verificar um trilhão (1012) de rotas por segundo, levaria mais de vinte bilhões de anos para verificar todas elas. Existe um algoritmo eficaz para resolver esse problema. ;) # --hints-- -`maximumPathSumII(testTriangle)` should return a number. +`maximumPathSumII(testTriangle)` deve retornar um número. ```js assert(typeof maximumPathSumII(_testTriangle) === 'number'); ``` -`maximumPathSumII(testTriangle)` should return 23. +`maximumPathSumII(testTriangle)` deve retornar 23. ```js assert.strictEqual(maximumPathSumII(_testTriangle), 23); ``` -`maximumPathSumII(numTriangle)` should return 7273. +`maximumPathSumII(numTriangle)` deve retornar 7273. ```js assert.strictEqual(maximumPathSumII(_numTriangle), 7273); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.md index 1ae580513f..37e8f4a2f8 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.md @@ -1,6 +1,6 @@ --- id: 5900f3b01000cf542c50fec3 -title: 'Problem 68: Magic 5-gon ring' +title: 'Problema 68: Anel de 5 linhas mágicas' challengeType: 5 forumTopicId: 302180 dashedName: problem-68-magic-5-gon-ring @@ -8,13 +8,13 @@ dashedName: problem-68-magic-5-gon-ring # --description-- -Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine. +Considere o seguinte anel de 3 linhas "mágicas" com números de 1 a 6. Note que ao somar os números de cada linha, o resultado é nove. -a completed example of a 3-gon ring +um exemplo completo de um anel de 3 linhas -Working **clockwise**, and starting from the group of three with the numerically lowest external node (4,3,2 in this example), each solution can be described uniquely. For example, the above solution can be described by the set: 4,3,2; 6,2,1; 5,1,3. +Trabalhando **no sentido horário**, e começando pelo grupo onde o nó externo é numericamente menor (4, 3, 2 neste exemplo), cada solução pode ser descrita de forma única. Por exemplo, a solução acima pode ser descrita pelo conjunto: 4,3,2; 6,2,1; 5,1,3. -It is possible to complete the ring with four different totals: 9, 10, 11, and 12. There are eight solutions in total. +É possível completar o anel com quatro totais diferentes: 9, 10, 11 e 12. No total, há oito soluções.
@@ -31,21 +31,21 @@ It is possible to complete the ring with four different totals: 9, 10, 11, and 1
-By concatenating each group it is possible to form 9-digit strings; the maximum string for a 3-gon ring is 432621513. +Ao concatenar cada grupo, é possível formar números de 9 algarismos; o maior número para um anel de 3 linhas é 432621513. -Using the numbers 1 to 10, and depending on arrangements, it is possible to form 16- and 17-digit strings. What is the maximum **16-digit** string for a "magic" 5-gon ring? +Usando os números de 1 a 10 e dependendo dos arranjos, é possível formar números de 16 e 17 algarismos. Qual é o maior número de **16 algarismos** em um anel de 5 linhas? -a blank diagram of a 5-gon ring +um diagrama em branco de um anel de 5 linhas # --hints-- -`magic5GonRing()` should return a number. +`magic5GonRing()` deve retornar um número. ```js assert(typeof magic5GonRing() === 'number'); ``` -`magic5GonRing()` should return 6531031914842725. +`magic5GonRing()` deve retornar 6531031914842725. ```js assert.strictEqual(magic5GonRing(), 6531031914842725); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-69-totient-maximum.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-69-totient-maximum.md index 2e538e324d..70b8d0a7ac 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-69-totient-maximum.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-69-totient-maximum.md @@ -1,6 +1,6 @@ --- id: 5900f3b11000cf542c50fec4 -title: 'Problem 69: Totient maximum' +title: 'Problema 69: Totiente máximo' challengeType: 5 forumTopicId: 302181 dashedName: problem-69-totient-maximum @@ -8,7 +8,7 @@ dashedName: problem-69-totient-maximum # --description-- -Euler's Totient function, ${\phi}(n)$ (sometimes called the phi function), is used to determine the number of numbers less than `n` which are relatively prime to `n`. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, ${\phi}(9) = 6$. +A função Totiente de Euler, ${\phi}(n)$ (às vezes chamada de função phi), é usada para determinar a quantidade de números menores que `n`, que são primos próximos de `n`. Por exemplo, 1, 2, 4, 5, 7 e 8 são todos inferiores a nove e primos relativos de nove, ${\phi}(9) = 6$.
@@ -26,37 +26,37 @@ Euler's Totient function, ${\phi}(n)$ (sometimes called the phi function), is us
-It can be seen that `n` = 6 produces a maximum $\displaystyle\frac{n}{{\phi}(n)}$ for `n` ≤ 10. +Aqui, vemos que `n` = 6 produz um máximo $\displaystyle\frac{n}{{\phi}(n)}$, onde `n` ≤ 10. -Find the value of `n` ≤ `limit` for which $\displaystyle\frac{n}{{\phi(n)}}$ is a maximum. +Calcule o valor de `n` ≤ `limit` onde $\displaystyle\frac{n}{{\phi(n)}}$ é um máximo. # --hints-- -`totientMaximum(10)` should return a number. +`totientMaximum(10)` deve retornar um número. ```js assert(typeof totientMaximum(10) === 'number'); ``` -`totientMaximum(10)` should return `6`. +`totientMaximum(10)` deve retornar `6`. ```js assert.strictEqual(totientMaximum(10), 6); ``` -`totientMaximum(10000)` should return `2310`. +`totientMaximum(10000)` deve retornar `2310`. ```js assert.strictEqual(totientMaximum(10000), 2310); ``` -`totientMaximum(500000)` should return `30030`. +`totientMaximum(500000)` deve retornar `30030`. ```js assert.strictEqual(totientMaximum(500000), 30030); ``` -`totientMaximum(1000000)` should return `510510`. +`totientMaximum(1000000)` deve retornar `510510`. ```js assert.strictEqual(totientMaximum(1000000), 510510); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-70-totient-permutation.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-70-totient-permutation.md index 09c3e10628..a895ff2632 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-70-totient-permutation.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-70-totient-permutation.md @@ -1,6 +1,6 @@ --- id: 5900f3b21000cf542c50fec5 -title: 'Problem 70: Totient permutation' +title: 'Problema 70: Permutações Totiente' challengeType: 5 forumTopicId: 302183 dashedName: problem-70-totient-permutation @@ -8,39 +8,39 @@ dashedName: problem-70-totient-permutation # --description-- -Euler's Totient function, ${\phi}(n)$ (sometimes called the phi function), is used to determine the number of positive numbers less than or equal to `n` which are relatively prime to `n`. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, ${\phi}(9) = 6$. The number 1 is considered to be relatively prime to every positive number, so ${\phi}(1) = 1$. +A função Totiente de Euler, ${\phi}(n)$ (às vezes chamada de função phi), é usada para determinar a quantidade de números menores que `n`, que são primos próximos de `n`. Por exemplo, 1, 2, 4, 5, 7 e 8 são todos inferiores a nove e primos relativos de nove, ${\phi}(9) = 6$. O número 1 é considerado um primo relativo para todos os números positivos, portanto ${\phi}(1) = 1$. -Interestingly, ${\phi}(87109) = 79180$, and it can be seen that 87109 is a permutation of 79180. +Curiosamente, ${\phi}(87109) = 79180$, e pode ser visto que 87109 é uma permutação de 79180. -Find the value of `n`, 1 < `n` < `limit`, for which ${\phi}(n)$ is a permutation of `n` and the ratio $\displaystyle\frac{n}{{\phi}(n)}$ produces a minimum. +Encontre o valor de `n`, 1 < `n` < `limit`, onde ${\phi}(n)$ é uma permutação de `n` e a razão $\displaystyle\frac{n}{{\phi}(n)}$ produz um mínimo. # --hints-- -`totientPermutation(10000)` should return a number. +`totientPermutation(10000)` deve retornar um número. ```js assert(typeof totientPermutation(10000) === 'number'); ``` -`totientPermutation(10000)` should return `4435`. +`totientPermutation(10000)` deve retornar `4435`. ```js assert.strictEqual(totientPermutation(10000), 4435); ``` -`totientPermutation(100000)` should return `75841`. +`totientPermutation(100000)` deve retornar `75841`. ```js assert.strictEqual(totientPermutation(100000), 75841); ``` -`totientPermutation(500000)` should return `474883`. +`totientPermutation(500000)` deve retornar `474883`. ```js assert.strictEqual(totientPermutation(500000), 474883); ``` -`totientPermutation(10000000)` should return `8319823`. +`totientPermutation(10000000)` deve retornar `8319823`. ```js assert.strictEqual(totientPermutation(10000000), 8319823); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md index 55a2e9b72f..27e213e6f8 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-71-ordered-fractions.md @@ -1,6 +1,6 @@ --- id: 5900f3b31000cf542c50fec6 -title: 'Problem 71: Ordered fractions' +title: 'Problema 71: Frações ordenadas' challengeType: 5 forumTopicId: 302184 dashedName: problem-71-ordered-fractions @@ -8,49 +8,49 @@ dashedName: problem-71-ordered-fractions # --description-- -Consider the fraction, $\frac{n}{d}$, where `n` and `d` are positive integers. If `n` < `d` and highest common factor, ${{HCF}(n, d)} = 1$, it is called a reduced proper fraction. +Considere a fração $\frac{n}{d}$, onde `n` e `d` são números inteiros e positivos. Se `n` < `d` e o maior divisor comum, ${{HCF}(n, d)} = 1$, ela é chamada de fração irredutível. -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +Se nós listarmos o conjunto de frações irredutíveis onde `d` = 8, em ordem ascendente, temos: $$\frac{1}{8}, \frac{1}{7}, \frac{1}{6}, \frac{1}{5}, \frac{1}{4}, \frac{2}{7}, \frac{1}{3}, \frac{3}{8}, \frac{\textbf2}{\textbf5}, \frac{3}{7}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{5}{8}, \frac{2}{3}, \frac{5}{7}, \frac{3}{4}, \frac{4}{5}, \frac{5}{6}, \frac{6}{7}, \frac{7}{8}$$ -It can be seen that $\frac{2}{5}$ is the fraction immediately to the left of $\frac{3}{7}$. +Podemos ver que $\frac{2}{5}$ está imediatamente à esquerda de $\frac{3}{7}$. -By listing the set of reduced proper fractions for `d` ≤ `limit` in ascending order of size, find the numerator of the fraction immediately to the left of $\frac{3}{7}$. +Ao listar o conjunto de frações irredutíveis em ordem ascendente, onde `d` ≤ `limit`, encontre o numerador da fração imediatamente à esquerda de $\frac{3}{7}$. # --hints-- -`orderedFractions(8)` should return a number. +`orderedFractions(8)` deve retornar um número. ```js assert(typeof orderedFractions(8) === 'number'); ``` -`orderedFractions(8)` should return `2`. +`orderedFractions(8)` deve retornar `2`. ```js assert.strictEqual(orderedFractions(8), 2); ``` -`orderedFractions(10)` should return `2`. +`orderedFractions(10)` deve retornar `2`. ```js assert.strictEqual(orderedFractions(10), 2); ``` -`orderedFractions(9994)` should return `4283`. +`orderedFractions(9994)` deve retornar `4283`. ```js assert.strictEqual(orderedFractions(9994), 4283); ``` -`orderedFractions(500000)` should return `214283`. +`orderedFractions(500000)` deve retornar `214283`. ```js assert.strictEqual(orderedFractions(500000), 214283); ``` -`orderedFractions(1000000)` should return `428570`. +`orderedFractions(1000000)` deve retornar `428570`. ```js assert.strictEqual(orderedFractions(1000000), 428570); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md index 3929bde7af..5f4a866174 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-72-counting-fractions.md @@ -1,6 +1,6 @@ --- id: 5900f3b41000cf542c50fec7 -title: 'Problem 72: Counting fractions' +title: 'Problema 72: Contando frações' challengeType: 5 forumTopicId: 302185 dashedName: problem-72-counting-fractions @@ -8,43 +8,43 @@ dashedName: problem-72-counting-fractions # --description-- -Consider the fraction, $\frac{n}{d}$, where `n` and `d` are positive integers. If `n` < `d` and highest common factor, ${HCF}(n, d) = 1$, it is called a reduced proper fraction. +Considere a fração $\frac{n}{d}$, onde `n` e `d` são números inteiros e positivos. Se `n` < `d` e o maior divisor comum, ${HCF}(n, d) = 1$, ela é chamada de fração irredutível. -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +Se nós listarmos o conjunto de frações irredutíveis onde `d` = 8, em ordem ascendente, temos: $$\frac{1}{8}, \frac{1}{7}, \frac{1}{6}, \frac{1}{5}, \frac{1}{4}, \frac{2}{7}, \frac{1}{3}, \frac{3}{8}, \frac{2}{5}, \frac{3}{7}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{5}{8}, \frac{2}{3}, \frac{5}{7}, \frac{3}{4}, \frac{4}{5}, \frac{5}{6}, \frac{6}{7}, \frac{7}{8}$$ -It can be seen that there are `21` elements in this set. +Podemos notar que há `21` elementos neste conjunto. -How many elements would be contained in the set of reduced proper fractions for `d` ≤ `limit`? +Quantos elementos existem no conjunto de frações irredutíveis onde `d` ≤ `limit`? # --hints-- -`countingFractions(8)` should return a number. +`countingFractions(8)` deve retornar um número. ```js assert(typeof countingFractions(8) === 'number'); ``` -`countingFractions(8)` should return `21`. +`countingFractions(8)` deve retornar `21`. ```js assert.strictEqual(countingFractions(8), 21); ``` -`countingFractions(20000)` should return `121590395`. +`countingFractions(20000)` deve retornar `121590395`. ```js assert.strictEqual(countingFractions(20000), 121590395); ``` -`countingFractions(500000)` should return `75991039675`. +`countingFractions(500000)` deve retornar `75991039675`. ```js assert.strictEqual(countingFractions(500000), 75991039675); ``` -`countingFractions(1000000)` should return `303963552391`. +`countingFractions(1000000)` deve retornar `303963552391`. ```js assert.strictEqual(countingFractions(1000000), 303963552391); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md index 10c1ae6ea8..69610cc890 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-73-counting-fractions-in-a-range.md @@ -1,6 +1,6 @@ --- id: 5900f3b61000cf542c50fec8 -title: 'Problem 73: Counting fractions in a range' +title: 'Problema 73: Contando frações em um intervalo' challengeType: 5 forumTopicId: 302186 dashedName: problem-73-counting-fractions-in-a-range @@ -8,43 +8,43 @@ dashedName: problem-73-counting-fractions-in-a-range # --description-- -Consider the fraction, $\frac{n}{d}$, where `n` and `d` are positive integers. If `n` < `d` and highest common factor, ${HCF}(n, d) = 1$, it is called a reduced proper fraction. +Considere a fração $\frac{n}{d}$, onde `n` e `d` são números inteiros e positivos. Se `n` < `d` e o maior divisor comum, ${HCF}(n, d) = 1$, ela é chamada de fração irredutível. -If we list the set of reduced proper fractions for `d` ≤ 8 in ascending order of size, we get: +Se nós listarmos o conjunto de frações irredutíveis onde `d` ≤ 8, em ordem ascendente, temos: $$\frac{1}{8}, \frac{1}{7}, \frac{1}{6}, \frac{1}{5}, \frac{1}{4}, \frac{2}{7}, \frac{1}{3}, \mathbf{\frac{3}{8}, \frac{2}{5}, \frac{3}{7}}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{5}{8}, \frac{2}{3}, \frac{5}{7}, \frac{3}{4}, \frac{4}{5}, \frac{5}{6}, \frac{6}{7}, \frac{7}{8}$$ -It can be seen that there are `3` fractions between $\frac{1}{3}$ and $\frac{1}{2}$. +Podemos notar que há `3` frações entre $\frac{1}{3}$ e $\frac{1}{2}$. -How many fractions lie between $\frac{1}{3}$ and $\frac{1}{2}$ in the sorted set of reduced proper fractions for `d` ≤ `limit`? +Quantas frações estão entre $\frac{1}{3}$ e $\frac{1}{2}$ no conjunto de frações irredutíveis, onde `d` ≤ `limit`? # --hints-- -`countingFractionsInARange(8)` should return a number. +`countingFractionsInARange(8)` deve retornar um número. ```js assert(typeof countingFractionsInARange(8) === 'number'); ``` -`countingFractionsInARange(8)` should return `3`. +`countingFractionsInARange(8)` deve retornar `3`. ```js assert.strictEqual(countingFractionsInARange(8), 3); ``` -`countingFractionsInARange(1000)` should return `50695`. +`countingFractionsInARange(1000)` deve retornar `50695`. ```js assert.strictEqual(countingFractionsInARange(1000), 50695); ``` -`countingFractionsInARange(6000)` should return `1823861`. +`countingFractionsInARange(6000)` deve retornar `1823861`. ```js assert.strictEqual(countingFractionsInARange(6000), 1823861); ``` -`countingFractionsInARange(12000)` should return `7295372`. +`countingFractionsInARange(12000)` deve retornar `7295372`. ```js assert.strictEqual(countingFractionsInARange(12000), 7295372); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-74-digit-factorial-chains.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-74-digit-factorial-chains.md index eb9a6e9d13..5bf0a28020 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-74-digit-factorial-chains.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-74-digit-factorial-chains.md @@ -1,6 +1,6 @@ --- id: 5900f3b61000cf542c50fec9 -title: 'Problem 74: Digit factorial chains' +title: 'Problema 74: Cadeia de fatoriais' challengeType: 5 forumTopicId: 302187 dashedName: problem-74-digit-factorial-chains @@ -8,49 +8,49 @@ dashedName: problem-74-digit-factorial-chains # --description-- -The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145: +O número 145 é conhecido pela propriedade onde a soma do fatorial de seus algarismos é igual a 145: $$1! + 4! + 5! = 1 + 24 + 120 = 145$$ -Perhaps less well known is 169, in that it produces the longest chain of numbers that link back to 169; it turns out that there are only three such loops that exist: +Talvez 169 seja menos conhecido. Esse número produz a maior cadeia de números que remonta a 169. Acontece que existem apenas três desses laços: $$\begin{align} &169 → 363601 → 1454 → 169\\\\ &871 → 45361 → 871\\\\ &872 → 45362 → 872\\\\ \end{align}$$ -It is not difficult to prove that EVERY starting number will eventually get stuck in a loop. For example, +Não é difícil provar que TODOS os números com que você iniciar ficarão presos em um ciclo. Por exemplo: $$\begin{align} &69 → 363600 → 1454 → 169 → 363601\\ (→ 1454)\\\\ &78 → 45360 → 871 → 45361\\ (→ 871)\\\\ &540 → 145\\ (→ 145)\\\\ \end{align}$$ -Starting with 69 produces a chain of five non-repeating terms, but the longest non-repeating chain with a starting number below one million is sixty terms. +O número 69 produz uma cadeia de cinco termos sem repetição. A cadeia de maior número sem repetição, iniciando com um número abaixo de um milhão, é de sessenta termos. -How many chains, with a starting number below `n`, contain exactly sixty non-repeating terms? +Quantas cadeias, com um número inicial abaixo de `n`, contém exatamente sessenta termos não repetidos? # --hints-- -`digitFactorialChains(2000)` should return a number. +`digitFactorialChains(2000)` deve retornar um número. ```js assert(typeof digitFactorialChains(2000) === 'number'); ``` -`digitFactorialChains(2000)` should return `6`. +`digitFactorialChains(2000)` deve retornar `6`. ```js assert.strictEqual(digitFactorialChains(2000), 6); ``` -`digitFactorialChains(100000)` should return `42`. +`digitFactorialChains(100000)` deve retornar `42`. ```js assert.strictEqual(digitFactorialChains(100000), 42); ``` -`digitFactorialChains(500000)` should return `282`. +`digitFactorialChains(500000)` deve retornar `282`. ```js assert.strictEqual(digitFactorialChains(500000), 282); ``` -`digitFactorialChains(1000000)` should return `402`. +`digitFactorialChains(1000000)` deve retornar `402`. ```js assert.strictEqual(digitFactorialChains(1000000), 402); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-76-counting-summations.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-76-counting-summations.md index bbc9618245..843fd752aa 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-76-counting-summations.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-76-counting-summations.md @@ -1,6 +1,6 @@ --- id: 5900f3b81000cf542c50fecb -title: 'Problem 76: Counting summations' +title: 'Problema 76: Contagem de somas' challengeType: 5 forumTopicId: 302189 dashedName: problem-76-counting-summations @@ -8,7 +8,7 @@ dashedName: problem-76-counting-summations # --description-- -It is possible to write five as a sum in exactly six different ways: +É possível chegar ao resultado 5 a partir de uma soma de seis formas diferentes:
4 + 1
@@ -19,35 +19,35 @@ It is possible to write five as a sum in exactly six different ways: 1 + 1 + 1 + 1 + 1

-How many different ways can `n` be written as a sum of at least two positive integers? +De quantas formas diferentes `n` pode ser escrito como o resultado de uma soma de pelo menos dois números inteiros positivos? # --hints-- -`countingSummations(5)` should return a number. +`countingSummations(5)` deve retornar um número. ```js assert(typeof countingSummations(5) === 'number'); ``` -`countingSummations(5)` should return `6`. +`countingSummations(5)` deve retornar `6`. ```js assert.strictEqual(countingSummations(5), 6); ``` -`countingSummations(20)` should return `626`. +`countingSummations(20)` deve retornar `626`. ```js assert.strictEqual(countingSummations(20), 626); ``` -`countingSummations(50)` should return `204225`. +`countingSummations(50)` deve retornar `204225`. ```js assert.strictEqual(countingSummations(50), 204225); ``` -`countingSummations(100)` should return `190569291`. +`countingSummations(100)` deve retornar `190569291`. ```js assert.strictEqual(countingSummations(100), 190569291); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-77-prime-summations.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-77-prime-summations.md index bd26cc3c69..e4728264b1 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-77-prime-summations.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-77-prime-summations.md @@ -1,6 +1,6 @@ --- id: 5900f3b91000cf542c50fecc -title: 'Problem 77: Prime summations' +title: 'Problema 77: Contagem de primos' challengeType: 5 forumTopicId: 302190 dashedName: problem-77-prime-summations @@ -8,7 +8,7 @@ dashedName: problem-77-prime-summations # --description-- -It is possible to write ten as the sum of primes in exactly five different ways: +É possível chegar a 10 como resultado a partir de uma soma de números primos de cinco formas diferentes:
7 + 3
@@ -18,35 +18,35 @@ It is possible to write ten as the sum of primes in exactly five different ways: 2 + 2 + 2 + 2 + 2

-What is the first value which can be written as the sum of primes in over `n` ways? +Qual é o primeiro valor que pode ser escrito como a soma de números primos de `n` maneiras? # --hints-- -`primeSummations(5)` should return a number. +`primeSummations(5)` deve retornar um número. ```js assert(typeof primeSummations(5) === 'number'); ``` -`primeSummations(5)` should return `11`. +`primeSummations(5)` deve retornar `11`. ```js assert.strictEqual(primeSummations(5), 11); ``` -`primeSummations(100)` should return `31`. +`primeSummations(100)` deve retornar `31`. ```js assert.strictEqual(primeSummations(100), 31); ``` -`primeSummations(1000)` should return `53`. +`primeSummations(1000)` deve retornar `53`. ```js assert.strictEqual(primeSummations(1000), 53); ``` -`primeSummations(5000)` should return `71`. +`primeSummations(5000)` deve retornar `71`. ```js assert.strictEqual(primeSummations(5000), 71); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/towers-of-hanoi.md b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/towers-of-hanoi.md index 4de9c851ba..ddabaa87f5 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/towers-of-hanoi.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/towers-of-hanoi.md @@ -1,6 +1,6 @@ --- id: 5951ed8945deab770972ae56 -title: Towers of Hanoi +title: Torres de Hanói challengeType: 5 forumTopicId: 302341 dashedName: towers-of-hanoi @@ -8,41 +8,41 @@ dashedName: towers-of-hanoi # --description-- -Solve the [Towers of Hanoi](https://en.wikipedia.org/wiki/Towers_of_Hanoi "wp: Towers_of_Hanoi") problem. +Resolva o problema das [Torres de Hanói](https://pt.wikipedia.org/wiki/Torre_de_Han%C3%B3i "wp: Torres_de_Hanoi"). -Your solution should accept the number of discs as the first parameters, and three string used to identify each of the three stacks of discs, for example `towerOfHanoi(4, 'A', 'B', 'C')`. The function should return an array of arrays containing the list of moves, source -> destination. +Sua solução deve aceitar o número de discos como os primeiros parâmetros, e três strings usadas para identificar cada uma das três pilhas de discos, por exemplo `towerOfHanoi(4, 'A', 'B', 'C')`. A função deve retornar um array de arrays contendo a lista de movimentos, origem -> destino. -For example, the array `[['A', 'C'], ['B', 'A']]` indicates that the 1st move was to move a disc from stack A to C, and the 2nd move was to move a disc from stack B to A. +Por exemplo, o array `[['A', 'C'], ['B', 'A']]` indica que o primeiro movimento foi mover um disco da pilha A para C, e o segundo movimento foi para mover um disco da pilha B para A.

# --hints-- -`towerOfHanoi` should be a function. +`towerOfHanoi` deve ser uma função. ```js assert(typeof towerOfHanoi === 'function'); ``` -`towerOfHanoi(3, ...)` should return 7 moves. +`towerOfHanoi(3, ...)` deve retornar 7 movimentos. ```js assert(res3.length === 7); ``` -`towerOfHanoi(3, 'A', 'B', 'C')` should return `[['A','B'], ['A','C'], ['B','C'], ['A','B'], ['C','A'], ['C','B'], ['A','B']]`. +`towerOfHanoi(3, 'A', 'B', 'C')` deve retornar `[['A','B'], ['A','C'], ['B','C'], ['A','B'], ['C','A'], ['C','B'], ['A','B']]`. ```js assert.deepEqual(towerOfHanoi(3, 'A', 'B', 'C'), res3Moves); ``` -`towerOfHanoi(5, "X", "Y", "Z")` 10th move should be Y -> X. +O décimo movimento da `towerOfHanoi(5, "X", "Y", "Z")` deve ser Y -> X. ```js assert.deepEqual(res5[9], ['Y', 'X']); ``` -`towerOfHanoi(7, 'A', 'B', 'C')` first ten moves should be `[['A','B'], ['A','C'], ['B','C'], ['A','B'], ['C','A'], ['C','B'], ['A','B'], ['A','C'], ['B','C'], ['B','A']]` +Os dez primeiros movimentos da `towerOfHanoi(7, 'A', 'B', 'C')` devem ser `[['A','B'], ['A','C'], ['B','C'], ['A','B'], ['C','A'], ['C','B'], ['A','B'], ['A','C'], ['B','C'], ['B','A']]` ```js assert.deepEqual(towerOfHanoi(7, 'A', 'B', 'C').slice(0, 10), res7First10Moves); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-frequency.md b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-frequency.md index 70d2d054dc..cb07ceaaa0 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-frequency.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-frequency.md @@ -1,6 +1,6 @@ --- id: 5e94a54cc7b022105bf0fd2c -title: Word frequency +title: Frequência de palavras challengeType: 5 forumTopicId: 393913 dashedName: word-frequency @@ -8,68 +8,68 @@ dashedName: word-frequency # --description-- -Given a text string and an integer n, return the n most common words in the file (and the number of their occurrences) in decreasing frequency. +Dados uma string e um número inteiro n, retorne as n palavras mais comuns no arquivo (e o número de ocorrências de cada uma) em frequência decrescente. # --instructions-- -Write a function to count the occurrences of each word and return the n most commons words along with the number of their occurences in decreasing frequency. +Escreva uma função para contar as ocorrências de cada palavra e retornar as n palavras mais comuns junto com o número de suas ocorrências em frequência decrescente. -The function should return a 2D array with each of the elements in the following form: `[word, freq]`. `word` should be the lowercase version of the word and `freq` the number denoting the count. +A função deve retornar um array 2D com cada um dos elementos na seguinte forma: `[word, freq]`. `word` deve ser a palavra toda em minúscula e `freq` o número que indica a contagem. -The function should return an empty array, if no string is provided. +A função deve retornar um array vazio se nenhuma string for fornecida. -The function should be case insensitive, for example, the strings "Hello" and "hello" should be treated the same. +A função não deve diferenciar maiúsculas de minúsculas. As strings "Hello" e "hello", por exemplo, devem ser tratadas da mesma forma. -You can treat words that have special characters such as underscores, dashes, apostrophes, commas, etc., as distinct words. +Você pode tratar as palavras com caracteres especiais como sublinhados, traços, apóstrofes, vírgulas, etc., como palavras distintas. -For example, given the string "Hello hello goodbye", your function should return `[['hello', 2], ['goodbye', 1]]`. +Por exemplo, dada a string "Hello Hello goodbye", sua função deve retornar `[['hello', 2], ['goodbye', 1]]`. # --hints-- -`wordFrequency` should be a function. +`wordFrequency` deve ser uma função. ```js assert(typeof wordFrequency == 'function'); ``` -`wordFrequency` should return an array. +`wordFrequency` deve retornar um array. ```js assert(Array.isArray(wordFrequency('test'))); ``` -`wordFrequency("Hello hello world", 2)` should return `[['hello', 2], ['world', 1]]` +`wordFrequency("Hello hello world", 2)` deve retornar `[['hello', 2], ['world', 1]]` ```js assert.deepEqual(wordFrequency(example_1, 2), example_1_solution); ``` -`wordFrequency("The quick brown fox jumped over the lazy dog", 1)` should return `[['the', 2]]` +`wordFrequency("The quick brown fox jumped over the lazy dog", 1)` deve retornar `[['the', 2]]` ```js assert.deepEqual(wordFrequency(example_2, 1), example_2_solution); ``` -`wordFrequency("Opensource opensource open-source open source", 1)` should return `[['opensource', 2]]` +`wordFrequency("Opensource opensource open-source open source", 1)` deve retornar `[['opensource', 2]]` ```js assert.deepEqual(wordFrequency(example_3, 1), example_3_solution); ``` -`wordFrequency("Apple App apply aPP aPPlE", 3)` should return `[['app', 2], ['apple', 2], ['apply', 1]]` or `[['apple', 2], ['app', 2], ['apply', 1]]` +`wordFrequency("Apple App apply aPP aPPlE", 3)` deve retornar `[['app', 2], ['apple', 2], ['apply', 1]]` ou `[['apple', 2], ['app', 2], ['apply', 1]]` ```js const arr = JSON.stringify(wordFrequency(example_4, 3)); assert(arr === example_4_solution_a || arr === example_4_solution_b); ``` -`wordFrequency("c d a d c a b d d c", 4)` should return `[['d', 4], ['c', 3], ['a', 2], ['b', 1]]` +`wordFrequency("c d a d c a b d d c", 4)` deve retornar `[['d', 4], ['c', 3], ['a', 2], ['b', 1]]` ```js assert.deepEqual(wordFrequency(example_5, 4), example_5_solution); ``` -`wordFrequency("", 5)` should return `[]` +`wordFrequency("", 5)` deve retornar `[]` ```js assert.deepEqual(wordFrequency(example_6, 5), example_6_solution); diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-wrap.md b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-wrap.md index 344be87802..5797544d53 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-wrap.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/rosetta-code/word-wrap.md @@ -1,6 +1,6 @@ --- id: 594810f028c0303b75339ad4 -title: Word wrap +title: Quebra de linha challengeType: 5 forumTopicId: 302344 dashedName: word-wrap @@ -8,52 +8,51 @@ dashedName: word-wrap # --description-- -Even today, with proportional fonts and complex layouts, there are still cases where you need to wrap text at a specified column. The basic task is to wrap a paragraph of text in a simple way. +Mesmo hoje, com fontes proporcionais e layouts complexos, ainda há casos em que você precisa quebrar o texto em uma determinada coluna. A tarefa básica é quebrar um parágrafo de um texto de uma forma simples. # --instructions-- -Write a function that can wrap this text to any number of characters. As an example, the text wrapped to 80 characters should look like the following: +Escreva uma função que possa quebrar este texto para qualquer número de caracteres. Como exemplo, o texto quebrado com 80 caracteres deve se parecer com o seguinte:
-Wrap text using a more sophisticated algorithm such as the Knuth and Plass TeX
-algorithm. If your language provides this, you get easy extra credit, but you
-must reference documentation indicating that the algorithm is something better
-than a simple minimum length algorithm.
+Quebre o texto usando um algoritmo mais sofisticado, como o algoritmo de Knuth e Plass TeX. Se o seu idioma fornece isso, você obtém crédito extra fácil, mas você
+deve fazer referência à documentação que indica que o algoritmo é algo melhor
+do que um simples algoritmo de comprimento mínimo.
 
# --hints-- -wrap should be a function. +wrap deve ser uma função. ```js assert.equal(typeof wrap, 'function'); ``` -wrap should return a string. +wrap deve retornar uma string. ```js assert.equal(typeof wrap('abc', 10), 'string'); ``` -wrap(80) should return 4 lines. +wrap(80) deve retornar 4 linhas. ```js assert(wrapped80.split('\n').length === 4); ``` -Your `wrap` function should return our expected text. +Sua função `wrap` deve retornar nosso texto esperado. ```js assert.equal(wrapped80.split('\n')[0], firstRow80); ``` -wrap(42) should return 7 lines. +wrap(42) deve retornar 7 linhas. ```js assert(wrapped42.split('\n').length === 7); ``` -Your `wrap` function should return our expected text. +A função `wrap` deve retornar nosso texto esperado. ```js assert.equal(wrapped42.split('\n')[0], firstRow42);