chore(i18n,curriculum): update translations (#43633)
This commit is contained in:
@ -11,9 +11,9 @@ dashedName: use-hex-code-for-specific-colors
|
|||||||
|
|
||||||
你知道在 CSS 裏面還有其他方式來代表顏色嗎? 其中一個方法叫十六進制編碼,簡稱 hex。
|
你知道在 CSS 裏面還有其他方式來代表顏色嗎? 其中一個方法叫十六進制編碼,簡稱 hex。
|
||||||
|
|
||||||
日常生活中,我們使用的計數方法一般是 <dfn>decimals</dfn>,或十進制,即使用數字 0 到 9 來表示。 而 <dfn>Hexadecimals</dfn>(或 <dfn>hex</dfn>)基於 16 位數字, 它包括 16 種不同字符。 像十進制一樣,0-9 的符號代表 0 到 9 的值。 然後,A、B、C、D、E、F 代表 10 至 15 的值。 總的來說,0 到 F 在十六進制裏代表數字,總共有 16 個值。 你可以在這裏訪問更多[關於十六進制的信息](https://en.wikipedia.org/wiki/Hexadecimal)。
|
日常生活中,我們使用的計數方法一般是 <dfn>decimals</dfn>,或十進制,即使用數字 0 到 9 來表示。 而 <dfn>Hexadecimals</dfn>(或 <dfn>hex</dfn>)基於 16 位數字, 它包括 16 種不同字符。 像十進制一樣,0-9 的符號代表 0 到 9 的值。 然後,A、B、C、D、E、F 代表 10 至 15 的值。 總的來說,0 到 F 在十六進制裏代表數字,總共有 16 個值。 你可以在[此處](https://www.freecodecamp.org/news/hexadecimal-number-system/)找到更多關於十六進制信息。
|
||||||
|
|
||||||
在 CSS 裏面,我們可以使用 6 個十六進制的數字來代表顏色,每兩個數字控制一種顏色,分別是紅(R)、綠(G)、藍(B)。 例如,`#000000` 代表黑色,同時也是最小的值。 你可以在 [RGB color system here](https://en.wikipedia.org/wiki/RGB_color_model) 找到更多的相關信息。
|
在 CSS 裏面,我們可以使用 6 個十六進制的數字來代表顏色,每兩個數字控制一種顏色,分別是紅(R)、綠(G)、藍(B)。 例如,`#000000` 代表黑色,同時也是最小的值。 你可以在[此處](https://www.freecodecamp.org/news/rgb-color-html-and-css-guide/#whatisthergbcolormodel)找到更多關於 RGB 顏色系統的信息。
|
||||||
|
|
||||||
```css
|
```css
|
||||||
body {
|
body {
|
||||||
|
@ -37,7 +37,7 @@ dashedName: add-images-to-your-website
|
|||||||
|
|
||||||
在 `main` 元素裏,給 `p` 元素前面插入一個 `img` 元素。
|
在 `main` 元素裏,給 `p` 元素前面插入一個 `img` 元素。
|
||||||
|
|
||||||
現在設置 `src` 屬性,使它指向網址 `https://www.bit.ly/fcc-relaxing-cat`。
|
現在設置 `src` 屬性,使其指向 url `https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg`
|
||||||
|
|
||||||
最後,不要忘記給 `img` 加上 `alt` 屬性。
|
最後,不要忘記給 `img` 加上 `alt` 屬性。
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ assert($('img').length);
|
|||||||
你的圖片應該有一個 `src` 屬性,其值爲貓咪圖片的 url。
|
你的圖片應該有一個 `src` 屬性,其值爲貓咪圖片的 url。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/^https:\/\/(www\.)?bit\.ly\/fcc-relaxing-cat$/i.test($('img').attr('src')));
|
assert(/^https:\/\/cdn\.freecodecamp\.org\/curriculum\/cat-photo-app\/relaxing-cat\.jpg$/i.test($('img').attr('src')));
|
||||||
```
|
```
|
||||||
|
|
||||||
你的圖片元素的 `alt` 屬性值不應爲空。
|
你的圖片元素的 `alt` 屬性值不應爲空。
|
||||||
@ -86,7 +86,7 @@ assert(
|
|||||||
```html
|
```html
|
||||||
<h2>CatPhotoApp</h2>
|
<h2>CatPhotoApp</h2>
|
||||||
<main>
|
<main>
|
||||||
<a href="#"><img src="https://www.bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
|
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
|
||||||
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
|
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
|
||||||
</main>
|
</main>
|
||||||
|
@ -29,7 +29,7 @@ var ourMusic = [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
這是一個包含一個對象的數組。 該對象有關於專輯的各種元數據(<dfn>metadata</dfn>)。 它也有一個嵌套的 `formats` 數組。 可以將專輯添加到頂級數組來增加更多的專輯記錄。 對象將數據以一種鍵 - 值對的形式保存。 在上面的示例中,`"artist": "Daft Punk"` 有一個鍵位 `artist` 值爲 `Daft Punk` 的屬性。 [JavaScript Object Notation](http://www.json.org/) 簡稱 `JSON` 是可以用於存儲數據的數據交換格式。
|
這是一個包含一個對象的數組。 該對象有關於專輯的各種元數據(<dfn>metadata</dfn>)。 它也有一個嵌套的 `formats` 數組。 可以將專輯添加到頂級數組來增加更多的專輯記錄。 對象將數據以一種鍵 - 值對的形式保存。 在上面的示例中,`"artist": "Daft Punk"` 有一個鍵爲 `artist` 值爲 `Daft Punk` 的屬性。 [JavaScript Object Notation](http://www.json.org/) 簡稱 `JSON` 是可以用於存儲數據的數據交換格式。
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
@ -42,10 +42,10 @@ assert.deepEqual(addTogether(23, 30), 53);
|
|||||||
assert.deepEqual(addTogether(5)(7), 12);
|
assert.deepEqual(addTogether(5)(7), 12);
|
||||||
```
|
```
|
||||||
|
|
||||||
`addTogether("http://bit.ly/IqT6zt")` 應返回 `undefined`。
|
`addTogether("https://www.youtube.com/watch?v=dQw4w9WgXcQ")` 應該返回 `undefined`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.isUndefined(addTogether('http://bit.ly/IqT6zt'));
|
assert.isUndefined(addTogether('https://www.youtube.com/watch?v=dQw4w9WgXcQ'));
|
||||||
```
|
```
|
||||||
|
|
||||||
`addTogether(2, "3")` 應返回 `undefined`。
|
`addTogether(2, "3")` 應返回 `undefined`。
|
||||||
|
@ -8,7 +8,7 @@ dashedName: make-images-mobile-responsive
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
首先,在已有的圖片下面添加一張新的圖片。 設置其 `src` 屬性爲 `https://bit.ly/fcc-running-cats`。
|
首先,在已有的圖片下面添加一張新的圖片。 將新圖片的 `src` 屬性設置爲 `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`。
|
||||||
|
|
||||||
如果圖片的大小恰恰和我們手機屏幕尺寸大小一樣自然是最好的。
|
如果圖片的大小恰恰和我們手機屏幕尺寸大小一樣自然是最好的。
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ assert($('img:eq(1)').hasClass('img-responsive'));
|
|||||||
assert(!$('img:eq(1)').hasClass('smaller-image'));
|
assert(!$('img:eq(1)').hasClass('smaller-image'));
|
||||||
```
|
```
|
||||||
|
|
||||||
新圖片的 `src` 屬性值應該爲 `https://bit.ly/fcc-running-cats`。
|
新圖片應該有一個值爲 `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg` 的 `src` 屬性。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert($('img:eq(1)').attr('src') === 'https://bit.ly/fcc-running-cats');
|
assert($('img:eq(1)').attr('src') === 'https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg');
|
||||||
```
|
```
|
||||||
|
|
||||||
確保新的 `img` 元素有一個閉合的尖括號。
|
確保新的 `img` 元素有一個閉合的尖括號。
|
||||||
@ -87,7 +87,7 @@ assert(
|
|||||||
|
|
||||||
<p>Click here for <a href="#">cat photos</a>.</p>
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
||||||
|
|
||||||
<a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
|
|
||||||
<p>Things cats love:</p>
|
<p>Things cats love:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@ -148,8 +148,8 @@ assert(
|
|||||||
|
|
||||||
<p>Click here for <a href="#">cat photos</a>.</p>
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
||||||
|
|
||||||
<a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
<img src="https://bit.ly/fcc-running-cats" class="img-responsive">
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg" class="img-responsive">
|
||||||
|
|
||||||
<p>Things cats love:</p>
|
<p>Things cats love:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -35,40 +35,66 @@ app.route('/login')
|
|||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
路由 /auth/github 應正確配置。
|
路由 `/auth/github` 應該是正確的。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(getUserInput) =>
|
async (getUserInput) => {
|
||||||
$.get(getUserInput('url') + '/_api/routes.js').then(
|
try {
|
||||||
(data) => {
|
const res = await fetch(getUserInput('url') + '/_api/routes.js');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.text();
|
||||||
assert.match(
|
assert.match(
|
||||||
data.replace(/\s/g, ''),
|
data.replace(/\s/g, ''),
|
||||||
/('|")\/auth\/github\/?\1[^]*?get.*?passport.authenticate.*?github/gi,
|
/passport.authenticate.*?github/g,
|
||||||
'Route auth/github should only call passport.authenticate with github'
|
'Route auth/github should only call passport.authenticate with github'
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
(xhr) => {
|
throw new Error(res.statusText);
|
||||||
throw new Error(xhr.statusText);
|
|
||||||
}
|
}
|
||||||
);
|
const res2 = await fetch(getUserInput('url') + '/_api/app-stack');
|
||||||
|
if (res2.ok) {
|
||||||
|
const data2 = JSON.parse(await res2.json());
|
||||||
|
const dataLayer = data2.find(layer => layer?.route?.path === '/auth/github');
|
||||||
|
assert.deepInclude(dataLayer?.route, { methods: {get: true}, path: "/auth/github"});
|
||||||
|
assert.deepInclude(dataLayer?.route?.stack?.[0], {method: "get", name: "authenticate"});
|
||||||
|
} else {
|
||||||
|
throw new Error(res2.statusText);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
路由 /auth/github/callback 應正確配置。
|
路由 `/auth/github/callback` 應該是正確的。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(getUserInput) =>
|
async (getUserInput) => {
|
||||||
$.get(getUserInput('url') + '/_api/routes.js').then(
|
try {
|
||||||
(data) => {
|
const res = await fetch(getUserInput('url') + '/_api/routes.js');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.text();
|
||||||
assert.match(
|
assert.match(
|
||||||
data.replace(/\s/g, ''),
|
data.replace(/\s/g, ''),
|
||||||
/('|")\/auth\/github\/callback\/?\1[^]*?get.*?passport.authenticate.*?github.*?failureRedirect:("|')\/\2/gi,
|
/failureRedirect:("|')\/\1/g,
|
||||||
'Route auth/github/callback should accept a get request and call passport.authenticate for github with a failure redirect to home'
|
'Route auth/github/callback should accept a get request and call passport.authenticate for github with a failure redirect to home'
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
(xhr) => {
|
throw new Error(res.statusText);
|
||||||
throw new Error(xhr.statusText);
|
|
||||||
}
|
}
|
||||||
);
|
const res2 = await fetch(getUserInput('url') + '/_api/app-stack');
|
||||||
|
if (res2.ok) {
|
||||||
|
const data2 = JSON.parse(await res2.json());
|
||||||
|
const dataLayer = data2.find(layer => layer?.route?.path === '/auth/github/callback');
|
||||||
|
assert.deepInclude(dataLayer?.route, { methods: {get: true}, path: "/auth/github/callback"});
|
||||||
|
assert.deepInclude(dataLayer?.route?.stack?.[0], {method: "get", name: "authenticate"});
|
||||||
|
} else {
|
||||||
|
throw new Error(res2.statusText);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# --solutions--
|
# --solutions--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3c81000cf542c50fedb
|
id: 5900f3c81000cf542c50fedb
|
||||||
title: 'Problem 92: Square digit chains'
|
title: '問題 92:平方數鏈'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302209
|
forumTopicId: 302209
|
||||||
dashedName: problem-92-square-digit-chains
|
dashedName: problem-92-square-digit-chains
|
||||||
@ -8,43 +8,43 @@ dashedName: problem-92-square-digit-chains
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.
|
將一個數字的每一位求平方再相加可以得到一個新的數字,不斷重複該過程,直到新的數字出現過爲止,可以得到一條數鏈。
|
||||||
|
|
||||||
For example,
|
舉個例子:
|
||||||
|
|
||||||
$$\begin{align} & 44 → 32 → 13 → 10 → \boldsymbol{1} → \boldsymbol{1}\\\\ & 85 → \boldsymbol{89} → 145 → 42 → 20 → 4 → 16 → 37 → 58 → \boldsymbol{89}\\\\ \end{align}$$
|
$$\begin{align} & 44 → 32 → 13 → 10 → \boldsymbol{1} → \boldsymbol{1}\\\\ & 85 → \boldsymbol{89} → 145 → 42 → 20 → 4 → 16 → 37 → 58 → \boldsymbol{89}\\\\ \end{align}$$
|
||||||
|
|
||||||
Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89.
|
可以發現,每條到達 1 或 89 的數鏈都會陷入循環。 最令人驚訝的是,從任意數字開始,數鏈最終都會到達 1 或 89。
|
||||||
|
|
||||||
How many starting numbers below `limit` will arrive at 89?
|
求出有多少個小於 `limit` 的數字最終會到達 89?
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`squareDigitChains(100)` should return a number.
|
`squareDigitChains(100)` 應該返回一個數字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof squareDigitChains(100) === 'number');
|
assert(typeof squareDigitChains(100) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(100)` should return `80`.
|
`squareDigitChains(100)` 應該返回 `80`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(100), 80);
|
assert.strictEqual(squareDigitChains(100), 80);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(1000)` should return `857`.
|
`squareDigitChains(1000)` 應該返回 `857`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(1000), 857);
|
assert.strictEqual(squareDigitChains(1000), 857);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(100000)` should return `85623`.
|
`squareDigitChains(100000)` 應該返回 `85623`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(100000), 85623);
|
assert.strictEqual(squareDigitChains(100000), 85623);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(10000000)` should return `8581146`.
|
`squareDigitChains(10000000)` 應該返回 `8581146`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(10000000), 8581146);
|
assert.strictEqual(squareDigitChains(10000000), 8581146);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3cc1000cf542c50fede
|
id: 5900f3cc1000cf542c50fede
|
||||||
title: 'Problem 95: Amicable chains'
|
title: '問題 95:友好的數鏈'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302212
|
forumTopicId: 302212
|
||||||
dashedName: problem-95-amicable-chains
|
dashedName: problem-95-amicable-chains
|
||||||
@ -8,45 +8,45 @@ dashedName: problem-95-amicable-chains
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
The proper divisors of a number are all the divisors excluding the number itself. For example, the proper divisors of 28 are 1, 2, 4, 7, and 14. As the sum of these divisors is equal to 28, we call it a perfect number.
|
一個數的真因子是除自身以外的其他因子。 例如,28 的真因子是 1、2、4、7 和 14。 由於這些真因子之和等於 28,我們稱 28 爲完全數,又稱完美數或完備數。
|
||||||
|
|
||||||
Interestingly the sum of the proper divisors of 220 is 284 and the sum of the proper divisors of 284 is 220, forming a chain of two numbers. For this reason, 220 and 284 are called an amicable pair.
|
有趣的是,220 的真因子之和爲 284,而 284 的真因子之和爲 220,形成了一條兩個數構成的鏈。 因此,220 和 284 被稱爲友好數對。
|
||||||
|
|
||||||
Perhaps less well known are longer chains. For example, starting with 12496, we form a chain of five numbers:
|
也許更長的鏈條鮮爲人知。 例如,從 12496 開始,可以形成一條五個數字的數鏈:
|
||||||
|
|
||||||
$$ 12496 → 14288 → 15472 → 14536 → 14264 \\,(→ 12496 → \cdots) $$
|
$$ 12496 → 14288 → 15472 → 14536 → 14264 \\,(→ 12496 → \cdots) $$
|
||||||
|
|
||||||
Since this chain returns to its starting point, it is called an amicable chain.
|
由於該鏈返回其起始點,因此稱爲友好數鏈。
|
||||||
|
|
||||||
Find the smallest member of the longest amicable chain with no element exceeding `limit`.
|
找出最長友好數鏈中的最小數字,要求該鏈中的每一個數字均不能超過給定的 `limit`。
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`amicableChains(300)` should return a number.
|
`amicableChains(300)` 應該返回一個數字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof amicableChains(300) === 'number');
|
assert(typeof amicableChains(300) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(300)` should return `220`.
|
`amicableChains(300)` 應該返回 `220`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(300), 220);
|
assert.strictEqual(amicableChains(300), 220);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(15000)` should return `220`.
|
`amicableChains(15000)` 應該返回 `220`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(15000), 220);
|
assert.strictEqual(amicableChains(15000), 220);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(100000)` should return `12496`.
|
`amicableChains(100000)` 應該返回 `12496`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(100000), 12496);
|
assert.strictEqual(amicableChains(100000), 12496);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(1000000)` should return `14316`.
|
`amicableChains(1000000)` 應該返回 `14316`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(1000000), 14316);
|
assert.strictEqual(amicableChains(1000000), 14316);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3cc1000cf542c50fedf
|
id: 5900f3cc1000cf542c50fedf
|
||||||
title: 'Problem 96: Su Doku'
|
title: '問題 96:數獨'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302213
|
forumTopicId: 302213
|
||||||
dashedName: problem-96-su-doku
|
dashedName: problem-96-su-doku
|
||||||
@ -8,7 +8,7 @@ dashedName: problem-96-su-doku
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Su Doku (Japanese meaning *number place*) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of Su Doku puzzles, however, is to replace the blanks (or zeros) in a 9 by 9 grid in such that each row, column, and 3 by 3 box contains each of the digits 1 to 9. Below is an example of a typical starting puzzle grid and its solution grid.
|
數獨(日語含義爲*數字位置*)是一個非常流行的解密遊戲。 它的起源尚不清楚,但必須歸功於萊昂哈德·歐拉(Leonhard Euler),他發明了一種類似的,但更加困難的解密遊戲,名叫拉丁方塊(Latin Squares)。 數獨的目標是用數字替換 9X9 網格中的空白(或零),使得每行,每列和每個 3X3 小網格中都只包含 1 到 9 這 9 個數字。 下面是一個示例,包含一個經典的謎題及其對應解。
|
||||||
|
|
||||||
<div style="margin: auto; background-color: white; padding: 10px; width: 80%; text-align: center;">
|
<div style="margin: auto; background-color: white; padding: 10px; width: 80%; text-align: center;">
|
||||||
<table border="0" cellpadding="0" cellspacing="0" align="center">
|
<table border="0" cellpadding="0" cellspacing="0" align="center">
|
||||||
@ -100,27 +100,27 @@ Su Doku (Japanese meaning *number place*) is the name given to a popular puzzle
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
A well constructed Su Doku puzzle has a unique solution and can be solved by logic, although it may be necessary to employ "guess and test" methods in order to eliminate options (there is much contested opinion over this). The complexity of the search determines the difficulty of the puzzle; the example above is considered easy because it can be solved by straight forward direct deduction.
|
一個構造良好的數獨謎題應該只有一個唯一的解,可以通過邏輯解出,雖然可能需要採用“猜測和測試”方法來排除選項(對此有很多爭議的意見)。 搜索的複雜性決定了謎題的難度;上面的示例很簡單,因此可以通過直接的邏輯推理來解出答案。
|
||||||
|
|
||||||
The `puzzlesArr` array contains different Su Doku puzzle strings ranging in difficulty, but all with unique solutions.
|
`puzzlesArr` 數組裏有若干個數獨謎題字符串,難度不一,但是每個謎題的解都是唯一的。
|
||||||
|
|
||||||
By solving all puzzles in `puzzlesArr`, find the sum of the 3-digit numbers found in the top left corner of each solution grid; for example, 483 is the 3-digit number found in the top left corner of the solution grid above.
|
通過解出 `puzzlesArr` 數組中所有謎題,返回所有解左上角三位數字之和;舉個例子,483 就是上述例子中左上角的三位數字。
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`suDoku(testPuzzles1)` should return a number.
|
`suDoku(testPuzzles1)` 應該返回一個數字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof suDoku(_testPuzzles1) === 'number');
|
assert(typeof suDoku(_testPuzzles1) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`suDoku(testPuzzles1)` should return `1190`.
|
`suDoku(testPuzzles1)` 應該返回 `1190`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(suDoku(_testPuzzles1), 1190);
|
assert.strictEqual(suDoku(_testPuzzles1), 1190);
|
||||||
```
|
```
|
||||||
|
|
||||||
`suDoku(testPuzzles2)` should return `24702`.
|
`suDoku(testPuzzles2)` 應該返回 `24702`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(suDoku(_testPuzzles2), 24702);
|
assert.strictEqual(suDoku(_testPuzzles2), 24702);
|
||||||
|
@ -11,9 +11,9 @@ dashedName: use-hex-code-for-specific-colors
|
|||||||
|
|
||||||
你知道在 CSS 里面还有其他方式来代表颜色吗? 其中一个方法叫十六进制编码,简称 hex。
|
你知道在 CSS 里面还有其他方式来代表颜色吗? 其中一个方法叫十六进制编码,简称 hex。
|
||||||
|
|
||||||
日常生活中,我们使用的计数方法一般是 <dfn>decimals</dfn>,或十进制,即使用数字 0 到 9 来表示。 而 <dfn>Hexadecimals</dfn>(或 <dfn>hex</dfn>)基于 16 位数字, 它包括 16 种不同字符。 像十进制一样,0-9 的符号代表 0 到 9 的值。 然后,A、B、C、D、E、F 代表 10 至 15 的值。 总的来说,0 到 F 在十六进制里代表数字,总共有 16 个值。 你可以在这里访问更多[关于十六进制的信息](https://en.wikipedia.org/wiki/Hexadecimal)。
|
日常生活中,我们使用的计数方法一般是 <dfn>decimals</dfn>,或十进制,即使用数字 0 到 9 来表示。 而 <dfn>Hexadecimals</dfn>(或 <dfn>hex</dfn>)基于 16 位数字, 它包括 16 种不同字符。 像十进制一样,0-9 的符号代表 0 到 9 的值。 然后,A、B、C、D、E、F 代表 10 至 15 的值。 总的来说,0 到 F 在十六进制里代表数字,总共有 16 个值。 你可以在[此处](https://www.freecodecamp.org/news/hexadecimal-number-system/)找到更多关于十六进制信息。
|
||||||
|
|
||||||
在 CSS 里面,我们可以使用 6 个十六进制的数字来代表颜色,每两个数字控制一种颜色,分别是红(R)、绿(G)、蓝(B)。 例如,`#000000` 代表黑色,同时也是最小的值。 你可以在 [RGB color system here](https://en.wikipedia.org/wiki/RGB_color_model) 找到更多的相关信息。
|
在 CSS 里面,我们可以使用 6 个十六进制的数字来代表颜色,每两个数字控制一种颜色,分别是红(R)、绿(G)、蓝(B)。 例如,`#000000` 代表黑色,同时也是最小的值。 你可以在[此处](https://www.freecodecamp.org/news/rgb-color-html-and-css-guide/#whatisthergbcolormodel)找到更多关于 RGB 颜色系统的信息。
|
||||||
|
|
||||||
```css
|
```css
|
||||||
body {
|
body {
|
||||||
|
@ -37,7 +37,7 @@ dashedName: add-images-to-your-website
|
|||||||
|
|
||||||
在 `main` 元素里,给 `p` 元素前面插入一个 `img` 元素。
|
在 `main` 元素里,给 `p` 元素前面插入一个 `img` 元素。
|
||||||
|
|
||||||
现在设置 `src` 属性,使它指向网址 `https://www.bit.ly/fcc-relaxing-cat`。
|
现在设置 `src` 属性,使其指向 url `https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg`
|
||||||
|
|
||||||
最后,不要忘记给 `img` 加上 `alt` 属性。
|
最后,不要忘记给 `img` 加上 `alt` 属性。
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ assert($('img').length);
|
|||||||
你的图片应该有一个 `src` 属性,其值为猫咪图片的 url。
|
你的图片应该有一个 `src` 属性,其值为猫咪图片的 url。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/^https:\/\/(www\.)?bit\.ly\/fcc-relaxing-cat$/i.test($('img').attr('src')));
|
assert(/^https:\/\/cdn\.freecodecamp\.org\/curriculum\/cat-photo-app\/relaxing-cat\.jpg$/i.test($('img').attr('src')));
|
||||||
```
|
```
|
||||||
|
|
||||||
你的图片元素的 `alt` 属性值不应为空。
|
你的图片元素的 `alt` 属性值不应为空。
|
||||||
@ -86,7 +86,7 @@ assert(
|
|||||||
```html
|
```html
|
||||||
<h2>CatPhotoApp</h2>
|
<h2>CatPhotoApp</h2>
|
||||||
<main>
|
<main>
|
||||||
<a href="#"><img src="https://www.bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
|
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
|
||||||
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
|
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
|
||||||
</main>
|
</main>
|
||||||
|
@ -29,7 +29,7 @@ var ourMusic = [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
这是一个包含一个对象的数组。 该对象有关于专辑的各种元数据(<dfn>metadata</dfn>)。 它也有一个嵌套的 `formats` 数组。 可以将专辑添加到顶级数组来增加更多的专辑记录。 对象将数据以一种键 - 值对的形式保存。 在上面的示例中,`"artist": "Daft Punk"` 有一个键位 `artist` 值为 `Daft Punk` 的属性。 [JavaScript Object Notation](http://www.json.org/) 简称 `JSON` 是可以用于存储数据的数据交换格式。
|
这是一个包含一个对象的数组。 该对象有关于专辑的各种元数据(<dfn>metadata</dfn>)。 它也有一个嵌套的 `formats` 数组。 可以将专辑添加到顶级数组来增加更多的专辑记录。 对象将数据以一种键 - 值对的形式保存。 在上面的示例中,`"artist": "Daft Punk"` 有一个键为 `artist` 值为 `Daft Punk` 的属性。 [JavaScript Object Notation](http://www.json.org/) 简称 `JSON` 是可以用于存储数据的数据交换格式。
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
@ -42,10 +42,10 @@ assert.deepEqual(addTogether(23, 30), 53);
|
|||||||
assert.deepEqual(addTogether(5)(7), 12);
|
assert.deepEqual(addTogether(5)(7), 12);
|
||||||
```
|
```
|
||||||
|
|
||||||
`addTogether("http://bit.ly/IqT6zt")` 应返回 `undefined`。
|
`addTogether("https://www.youtube.com/watch?v=dQw4w9WgXcQ")` 应该返回 `undefined`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.isUndefined(addTogether('http://bit.ly/IqT6zt'));
|
assert.isUndefined(addTogether('https://www.youtube.com/watch?v=dQw4w9WgXcQ'));
|
||||||
```
|
```
|
||||||
|
|
||||||
`addTogether(2, "3")` 应返回 `undefined`。
|
`addTogether(2, "3")` 应返回 `undefined`。
|
||||||
|
@ -8,7 +8,7 @@ dashedName: make-images-mobile-responsive
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
首先,在已有的图片下面添加一张新的图片。 设置其 `src` 属性为 `https://bit.ly/fcc-running-cats`。
|
首先,在已有的图片下面添加一张新的图片。 将新图片的 `src` 属性设置为 `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`。
|
||||||
|
|
||||||
如果图片的大小恰恰和我们手机屏幕尺寸大小一样自然是最好的。
|
如果图片的大小恰恰和我们手机屏幕尺寸大小一样自然是最好的。
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ assert($('img:eq(1)').hasClass('img-responsive'));
|
|||||||
assert(!$('img:eq(1)').hasClass('smaller-image'));
|
assert(!$('img:eq(1)').hasClass('smaller-image'));
|
||||||
```
|
```
|
||||||
|
|
||||||
新图片的 `src` 属性值应该为 `https://bit.ly/fcc-running-cats`。
|
新图片应该有一个值为 `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg` 的 `src` 属性。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert($('img:eq(1)').attr('src') === 'https://bit.ly/fcc-running-cats');
|
assert($('img:eq(1)').attr('src') === 'https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg');
|
||||||
```
|
```
|
||||||
|
|
||||||
确保新的 `img` 元素有一个闭合的尖括号。
|
确保新的 `img` 元素有一个闭合的尖括号。
|
||||||
@ -87,7 +87,7 @@ assert(
|
|||||||
|
|
||||||
<p>Click here for <a href="#">cat photos</a>.</p>
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
||||||
|
|
||||||
<a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
|
|
||||||
<p>Things cats love:</p>
|
<p>Things cats love:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@ -148,8 +148,8 @@ assert(
|
|||||||
|
|
||||||
<p>Click here for <a href="#">cat photos</a>.</p>
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
||||||
|
|
||||||
<a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
||||||
<img src="https://bit.ly/fcc-running-cats" class="img-responsive">
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg" class="img-responsive">
|
||||||
|
|
||||||
<p>Things cats love:</p>
|
<p>Things cats love:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -35,40 +35,66 @@ app.route('/login')
|
|||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
路由 /auth/github 应正确配置。
|
路由 `/auth/github` 应该是正确的。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(getUserInput) =>
|
async (getUserInput) => {
|
||||||
$.get(getUserInput('url') + '/_api/routes.js').then(
|
try {
|
||||||
(data) => {
|
const res = await fetch(getUserInput('url') + '/_api/routes.js');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.text();
|
||||||
assert.match(
|
assert.match(
|
||||||
data.replace(/\s/g, ''),
|
data.replace(/\s/g, ''),
|
||||||
/('|")\/auth\/github\/?\1[^]*?get.*?passport.authenticate.*?github/gi,
|
/passport.authenticate.*?github/g,
|
||||||
'Route auth/github should only call passport.authenticate with github'
|
'Route auth/github should only call passport.authenticate with github'
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
(xhr) => {
|
throw new Error(res.statusText);
|
||||||
throw new Error(xhr.statusText);
|
|
||||||
}
|
}
|
||||||
);
|
const res2 = await fetch(getUserInput('url') + '/_api/app-stack');
|
||||||
|
if (res2.ok) {
|
||||||
|
const data2 = JSON.parse(await res2.json());
|
||||||
|
const dataLayer = data2.find(layer => layer?.route?.path === '/auth/github');
|
||||||
|
assert.deepInclude(dataLayer?.route, { methods: {get: true}, path: "/auth/github"});
|
||||||
|
assert.deepInclude(dataLayer?.route?.stack?.[0], {method: "get", name: "authenticate"});
|
||||||
|
} else {
|
||||||
|
throw new Error(res2.statusText);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
路由 /auth/github/callback 应正确配置。
|
路由 `/auth/github/callback` 应该是正确的。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(getUserInput) =>
|
async (getUserInput) => {
|
||||||
$.get(getUserInput('url') + '/_api/routes.js').then(
|
try {
|
||||||
(data) => {
|
const res = await fetch(getUserInput('url') + '/_api/routes.js');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.text();
|
||||||
assert.match(
|
assert.match(
|
||||||
data.replace(/\s/g, ''),
|
data.replace(/\s/g, ''),
|
||||||
/('|")\/auth\/github\/callback\/?\1[^]*?get.*?passport.authenticate.*?github.*?failureRedirect:("|')\/\2/gi,
|
/failureRedirect:("|')\/\1/g,
|
||||||
'Route auth/github/callback should accept a get request and call passport.authenticate for github with a failure redirect to home'
|
'Route auth/github/callback should accept a get request and call passport.authenticate for github with a failure redirect to home'
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
(xhr) => {
|
throw new Error(res.statusText);
|
||||||
throw new Error(xhr.statusText);
|
|
||||||
}
|
}
|
||||||
);
|
const res2 = await fetch(getUserInput('url') + '/_api/app-stack');
|
||||||
|
if (res2.ok) {
|
||||||
|
const data2 = JSON.parse(await res2.json());
|
||||||
|
const dataLayer = data2.find(layer => layer?.route?.path === '/auth/github/callback');
|
||||||
|
assert.deepInclude(dataLayer?.route, { methods: {get: true}, path: "/auth/github/callback"});
|
||||||
|
assert.deepInclude(dataLayer?.route?.stack?.[0], {method: "get", name: "authenticate"});
|
||||||
|
} else {
|
||||||
|
throw new Error(res2.statusText);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# --solutions--
|
# --solutions--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3c81000cf542c50fedb
|
id: 5900f3c81000cf542c50fedb
|
||||||
title: 'Problem 92: Square digit chains'
|
title: '问题 92:平方数链'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302209
|
forumTopicId: 302209
|
||||||
dashedName: problem-92-square-digit-chains
|
dashedName: problem-92-square-digit-chains
|
||||||
@ -8,43 +8,43 @@ dashedName: problem-92-square-digit-chains
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.
|
将一个数字的每一位求平方再相加可以得到一个新的数字,不断重复该过程,直到新的数字出现过为止,可以得到一条数链。
|
||||||
|
|
||||||
For example,
|
举个例子:
|
||||||
|
|
||||||
$$\begin{align} & 44 → 32 → 13 → 10 → \boldsymbol{1} → \boldsymbol{1}\\\\ & 85 → \boldsymbol{89} → 145 → 42 → 20 → 4 → 16 → 37 → 58 → \boldsymbol{89}\\\\ \end{align}$$
|
$$\begin{align} & 44 → 32 → 13 → 10 → \boldsymbol{1} → \boldsymbol{1}\\\\ & 85 → \boldsymbol{89} → 145 → 42 → 20 → 4 → 16 → 37 → 58 → \boldsymbol{89}\\\\ \end{align}$$
|
||||||
|
|
||||||
Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89.
|
可以发现,每条到达 1 或 89 的数链都会陷入循环。 最令人惊讶的是,从任意数字开始,数链最终都会到达 1 或 89。
|
||||||
|
|
||||||
How many starting numbers below `limit` will arrive at 89?
|
求出有多少个小于 `limit` 的数字最终会到达 89?
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`squareDigitChains(100)` should return a number.
|
`squareDigitChains(100)` 应该返回一个数字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof squareDigitChains(100) === 'number');
|
assert(typeof squareDigitChains(100) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(100)` should return `80`.
|
`squareDigitChains(100)` 应该返回 `80`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(100), 80);
|
assert.strictEqual(squareDigitChains(100), 80);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(1000)` should return `857`.
|
`squareDigitChains(1000)` 应该返回 `857`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(1000), 857);
|
assert.strictEqual(squareDigitChains(1000), 857);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(100000)` should return `85623`.
|
`squareDigitChains(100000)` 应该返回 `85623`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(100000), 85623);
|
assert.strictEqual(squareDigitChains(100000), 85623);
|
||||||
```
|
```
|
||||||
|
|
||||||
`squareDigitChains(10000000)` should return `8581146`.
|
`squareDigitChains(10000000)` 应该返回 `8581146`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(squareDigitChains(10000000), 8581146);
|
assert.strictEqual(squareDigitChains(10000000), 8581146);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3cc1000cf542c50fede
|
id: 5900f3cc1000cf542c50fede
|
||||||
title: 'Problem 95: Amicable chains'
|
title: '问题 95:友好的数链'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302212
|
forumTopicId: 302212
|
||||||
dashedName: problem-95-amicable-chains
|
dashedName: problem-95-amicable-chains
|
||||||
@ -8,45 +8,45 @@ dashedName: problem-95-amicable-chains
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
The proper divisors of a number are all the divisors excluding the number itself. For example, the proper divisors of 28 are 1, 2, 4, 7, and 14. As the sum of these divisors is equal to 28, we call it a perfect number.
|
一个数的真因子是除自身以外的其他因子。 例如,28 的真因子是 1、2、4、7 和 14。 由于这些真因子之和等于 28,我们称 28 为完全数,又称完美数或完备数。
|
||||||
|
|
||||||
Interestingly the sum of the proper divisors of 220 is 284 and the sum of the proper divisors of 284 is 220, forming a chain of two numbers. For this reason, 220 and 284 are called an amicable pair.
|
有趣的是,220 的真因子之和为 284,而 284 的真因子之和为 220,形成了一条两个数构成的链。 因此,220 和 284 被称为友好数对。
|
||||||
|
|
||||||
Perhaps less well known are longer chains. For example, starting with 12496, we form a chain of five numbers:
|
也许更长的链条鲜为人知。 例如,从 12496 开始,可以形成一条五个数字的数链:
|
||||||
|
|
||||||
$$ 12496 → 14288 → 15472 → 14536 → 14264 \\,(→ 12496 → \cdots) $$
|
$$ 12496 → 14288 → 15472 → 14536 → 14264 \\,(→ 12496 → \cdots) $$
|
||||||
|
|
||||||
Since this chain returns to its starting point, it is called an amicable chain.
|
由于该链返回其起始点,因此称为友好数链。
|
||||||
|
|
||||||
Find the smallest member of the longest amicable chain with no element exceeding `limit`.
|
找出最长友好数链中的最小数字,要求该链中的每一个数字均不能超过给定的 `limit`。
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`amicableChains(300)` should return a number.
|
`amicableChains(300)` 应该返回一个数字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof amicableChains(300) === 'number');
|
assert(typeof amicableChains(300) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(300)` should return `220`.
|
`amicableChains(300)` 应该返回 `220`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(300), 220);
|
assert.strictEqual(amicableChains(300), 220);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(15000)` should return `220`.
|
`amicableChains(15000)` 应该返回 `220`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(15000), 220);
|
assert.strictEqual(amicableChains(15000), 220);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(100000)` should return `12496`.
|
`amicableChains(100000)` 应该返回 `12496`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(100000), 12496);
|
assert.strictEqual(amicableChains(100000), 12496);
|
||||||
```
|
```
|
||||||
|
|
||||||
`amicableChains(1000000)` should return `14316`.
|
`amicableChains(1000000)` 应该返回 `14316`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(amicableChains(1000000), 14316);
|
assert.strictEqual(amicableChains(1000000), 14316);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 5900f3cc1000cf542c50fedf
|
id: 5900f3cc1000cf542c50fedf
|
||||||
title: 'Problem 96: Su Doku'
|
title: '问题 96:数独'
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 302213
|
forumTopicId: 302213
|
||||||
dashedName: problem-96-su-doku
|
dashedName: problem-96-su-doku
|
||||||
@ -8,7 +8,7 @@ dashedName: problem-96-su-doku
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Su Doku (Japanese meaning *number place*) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of Su Doku puzzles, however, is to replace the blanks (or zeros) in a 9 by 9 grid in such that each row, column, and 3 by 3 box contains each of the digits 1 to 9. Below is an example of a typical starting puzzle grid and its solution grid.
|
数独(日语含义为*数字位置*)是一个非常流行的解密游戏。 它的起源尚不清楚,但必须归功于莱昂哈德·欧拉(Leonhard Euler),他发明了一种类似的,但更加困难的解密游戏,名叫拉丁方块(Latin Squares)。 数独的目标是用数字替换 9X9 网格中的空白(或零),使得每行,每列和每个 3X3 小网格中都只包含 1 到 9 这 9 个数字。 下面是一个示例,包含一个经典的谜题及其对应解。
|
||||||
|
|
||||||
<div style="margin: auto; background-color: white; padding: 10px; width: 80%; text-align: center;">
|
<div style="margin: auto; background-color: white; padding: 10px; width: 80%; text-align: center;">
|
||||||
<table border="0" cellpadding="0" cellspacing="0" align="center">
|
<table border="0" cellpadding="0" cellspacing="0" align="center">
|
||||||
@ -100,27 +100,27 @@ Su Doku (Japanese meaning *number place*) is the name given to a popular puzzle
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
A well constructed Su Doku puzzle has a unique solution and can be solved by logic, although it may be necessary to employ "guess and test" methods in order to eliminate options (there is much contested opinion over this). The complexity of the search determines the difficulty of the puzzle; the example above is considered easy because it can be solved by straight forward direct deduction.
|
一个构造良好的数独谜题应该只有一个唯一的解,可以通过逻辑解出,虽然可能需要采用“猜测和测试”方法来排除选项(对此有很多争议的意见)。 搜索的复杂性决定了谜题的难度;上面的示例很简单,因此可以通过直接的逻辑推理来解出答案。
|
||||||
|
|
||||||
The `puzzlesArr` array contains different Su Doku puzzle strings ranging in difficulty, but all with unique solutions.
|
`puzzlesArr` 数组里有若干个数独谜题字符串,难度不一,但是每个谜题的解都是唯一的。
|
||||||
|
|
||||||
By solving all puzzles in `puzzlesArr`, find the sum of the 3-digit numbers found in the top left corner of each solution grid; for example, 483 is the 3-digit number found in the top left corner of the solution grid above.
|
通过解出 `puzzlesArr` 数组中所有谜题,返回所有解左上角三位数字之和;举个例子,483 就是上述例子中左上角的三位数字。
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`suDoku(testPuzzles1)` should return a number.
|
`suDoku(testPuzzles1)` 应该返回一个数字。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof suDoku(_testPuzzles1) === 'number');
|
assert(typeof suDoku(_testPuzzles1) === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
`suDoku(testPuzzles1)` should return `1190`.
|
`suDoku(testPuzzles1)` 应该返回 `1190`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(suDoku(_testPuzzles1), 1190);
|
assert.strictEqual(suDoku(_testPuzzles1), 1190);
|
||||||
```
|
```
|
||||||
|
|
||||||
`suDoku(testPuzzles2)` should return `24702`.
|
`suDoku(testPuzzles2)` 应该返回 `24702`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.strictEqual(suDoku(_testPuzzles2), 24702);
|
assert.strictEqual(suDoku(_testPuzzles2), 24702);
|
||||||
|
Reference in New Issue
Block a user