chore(i18n,curriculum): processed translations (#44193)

This commit is contained in:
camperbot
2021-11-17 06:20:53 -08:00
committed by GitHub
parent 8812e6b3ac
commit 9f9fb63caa
47 changed files with 417 additions and 413 deletions

View File

@ -22,7 +22,7 @@ dashedName: build-a-markdown-previewer
**需求 4** 當在具有 `#editor` 屬性的元素內輸入 GitHub 風格的 markdown 內容時,文本應該以 HTML 的形式,把所鍵入的內容渲染在具有 `#preview` 屬性的元素中(提示:不需要自己解析 Markdown——可以引入一個叫做 Marked 的庫來完成這項工作:<https://cdnjs.com/libraries/marked>)。
**需求 5** 當 Markdown 預覽器首次加載時,具有 `#editor` 屬性的元素內的默認內容應該包含以下每個種類的至少一段有效的 Markdown 代碼標題H1 標籤、次級標題H2 標籤)、鏈接、行內代碼、代碼塊、列表、引用塊、圖片、加粗文本。
**需求 5** 當 Markdown 預覽器首次加載時,具有 `#editor` 屬性的元素內的默認內容應該包含以下每個種類的至少一段有效的 Markdown 代碼:標題元素H1 標籤)、次級標題元素H2 標籤)、鏈接、行內代碼、代碼塊、列表、引用塊、圖片、加粗文本。
**需求 6** 當 Markdown 預覽器首次加載時,具有 `#editor` 屬性的元素內容應該以 HTML 的形式渲染在具有 `#preview` 屬性的元素中。

View File

@ -14,67 +14,54 @@ dashedName: access-props-using-this-props
# --instructions--
在父組件 `ResetPassword` 中渲染 `ReturnTempPassword` 組件的一個實例。 在這裏, `ReturnTempPassword` 提供一個 `tempPassword` prop並賦值一個長度至少爲 8 個字符的字符串。 在子組件 `ReturnTempPassword`,訪問 `strong` 標籤`tempPassword` prop以確保用戶看到臨時密碼
在父組件 `App` 中渲染 `Welcome` 組件的一個實例。 在這裏, `Welcome` 一個 `name` prop給它賦值一個字符串。 在 `Welcome` 的子節點裏,訪問 `strong` 標籤`name` prop
# --hints--
`ResetPassword` 組件應返回單個 `div` 元素。
`App` 組件應返回單個 `div` 元素。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return mockedComponent.children().type() === 'div';
})()
);
```
`ResetPassword`第四個子組件應該是 `ReturnTempPassword` 組件。
`App` 的子組件應該是 `Welcome` 組件。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return (
mockedComponent.children().childAt(3).name() === 'ReturnTempPassword'
mockedComponent.children().childAt(0).name() === 'Welcome'
);
})()
);
```
`ReturnTempPassword` 組件應該有一個名爲 `tempPassword` 的屬性
`Welcome` 組件應該有一個名爲 `name` 的 prop
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
return mockedComponent.find('ReturnTempPassword').props().tempPassword;
const mockedComponent = Enzyme.mount(React.createElement(App));
return mockedComponent.find('Welcome').props().name;
})()
);
```
`ReturnTempPassword` 組件的 `tempPassword` prop 值應該是一個字符串,至少爲 8 個字符。
`Welcome` 組件應顯示你在 `strong` 標籤中作爲 `name` 屬性傳遞的字符
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const temp = mockedComponent.find('ReturnTempPassword').props()
.tempPassword;
return typeof temp === 'string' && temp.length >= 8;
})()
);
```
`ReturnTempPassword` 組件應該顯示作爲 `tempPassword` prop 創建的密碼,並且密碼被包裹在 `strong` 標籤中。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return (
mockedComponent.find('strong').text() ===
mockedComponent.find('ReturnTempPassword').props().tempPassword
mockedComponent.find('Welcome').props().name
);
})()
);
@ -85,13 +72,13 @@ assert(
## --after-user-code--
```jsx
ReactDOM.render(<ResetPassword />, document.getElementById('root'))
ReactDOM.render(<App />, document.getElementById('root'))
```
## --seed-contents--
```jsx
class ReturnTempPassword extends React.Component {
class App extends React.Component {
constructor(props) {
super(props);
@ -100,14 +87,14 @@ class ReturnTempPassword extends React.Component {
return (
<div>
{ /* Change code below this line */ }
<p>Your temporary password is: <strong></strong></p>
<Welcome />
{ /* Change code above this line */ }
</div>
);
}
};
class ResetPassword extends React.Component {
class Welcome extends React.Component {
constructor(props) {
super(props);
@ -115,11 +102,8 @@ class ResetPassword extends React.Component {
render() {
return (
<div>
<h2>Reset Password</h2>
<h3>We've generated a new temporary password for you.</h3>
<h3>Please reset this password from your account settings ASAP.</h3>
{ /* Change code below this line */ }
<p>Hello, <strong></strong>!</p>
{ /* Change code above this line */ }
</div>
);
@ -130,7 +114,7 @@ class ResetPassword extends React.Component {
# --solutions--
```jsx
class ReturnTempPassword extends React.Component {
class Welcome extends React.Component {
constructor(props) {
super(props);
@ -138,13 +122,15 @@ class ReturnTempPassword extends React.Component {
render() {
return (
<div>
<p>Your temporary password is: <strong>{this.props.tempPassword}</strong></p>
{ /* Change code below this line */ }
<p>Hello, <strong>{this.props.name}</strong>!</p>
{ /* Change code above this line */ }
</div>
);
}
};
class ResetPassword extends React.Component {
class App extends React.Component {
constructor(props) {
super(props);
@ -152,11 +138,8 @@ class ResetPassword extends React.Component {
render() {
return (
<div>
<h2>Reset Password</h2>
<h3>We've generated a new temporary password for you.</h3>
<h3>Please reset this password from your account settings ASAP.</h3>
{ /* Change code below this line */ }
<ReturnTempPassword tempPassword="serrPbqrPnzc" />
<Welcome name="Quincy"/>
{ /* Change code above this line */ }
</div>
);

View File

@ -14,7 +14,7 @@ dashedName: compose-react-components
在代碼編輯器中,`TypesOfFood` 組件已經渲染了一個名爲 `Vegetables` 的組件。 此外,還有上次挑戰中的 `Fruits` 組件。
`Fruits` 中嵌套兩個組件,首先 `NonCitrus`,然後是 `Citrus` 這兩個組件都已經引入。 接下來,將 `Fruits` 類組件嵌到 `TypesOfFood` 組件中,位於 `h1` 標題下方和 `Vegetables` 上方。 結果應該是一系列嵌套的組件,它們使用兩種不同的組件類型。
`Fruits` 中嵌套兩個組件,首先 `NonCitrus`,然後是 `Citrus` 這兩個組件都已經引入。 接下來,將 `Fruits` 類組件嵌`TypesOfFood` 組件中,位於 `h1` 標題元素下方和 `Vegetables` 上方。 結果應該是一系列嵌套的組件,它們使用兩種不同的組件類型。
# --hints--

View File

@ -109,7 +109,7 @@ assert(
);
```
`h1`頭應該從組件的 state 渲染 `submit` 字段的值。
`h1`題元素應該渲染從組件的狀態 `submit` 字段獲取的值。
```js
(() => {

View File

@ -38,7 +38,7 @@ class Kitten extends React.Component {
assert(Enzyme.shallow(React.createElement(MyComponent)).type() === 'div');
```
返回的 `div` 中應該渲染一個 `h1` 標題。
返回的 `div` 中應該渲染一個 `h1` 標題元素
```js
assert(
@ -48,7 +48,7 @@ assert(
);
```
`h1` 標題中應該包含字符串 `Hello React!`
`h1` 標題元素中應該包含字符串 `Hello React!`
```js
assert(

View File

@ -27,7 +27,7 @@ assert(
);
```
`MyComponent` 應該在 `div` 中渲染一個 `h1` 標題。
`MyComponent` 應該在 `div` 中渲染一個 `h1` 標題元素
```js
assert(
@ -44,7 +44,7 @@ assert(
assert(/<h1>\n*\s*\{\s*name\s*\}\s*\n*<\/h1>/.test(getUserInput('index')));
```
渲染的 `h1` 標題中應該包含一段文本,這段文本是從組件的 state 中渲染出來的
渲染的 `h1` 標題元素應包含從組件狀態渲染的文本
```js
async () => {

View File

@ -33,7 +33,7 @@ assert(
);
```
`MyComponent` 應該在 `div` 中渲染一個 `h1` 標題。
`MyComponent` 應該在 `div` 中渲染一個 `h1` 標題元素
```js
assert(
@ -43,7 +43,7 @@ assert(
);
```
渲染的 `h1` 標題應該只包含一段文本,這段文本是從組件的 state 中渲染出來的
渲染的 `h1` 標題元素應該只包含從組件狀態渲染的文本
```js
async () => {

View File

@ -35,13 +35,13 @@ assert(
);
```
`MyComponent` 應該渲染一個 `h1` 標題。
`MyComponent` 應該渲染一個 `h1` 標題元素
```js
assert(Enzyme.mount(React.createElement(MyComponent)).find('h1').length === 1);
```
渲染的 `h1` 標題中應該包含一段文本,這段文本是從組件的 state 中渲染出來的
渲染的 `h1` 標題元素應包含從組件狀態渲染的文本
```js
async () => {

View File

@ -77,7 +77,7 @@ assert(
);
```
mixin 應該有一個 `@else if` 語句來檢查 `$val` 是否等於 `heavy`,並設置 `border``3px solid black`
mixin 應該有一個 `@else if` 語句來檢查 `$val` 是否等於 `heavy`,並設置 `border``6px solid black`
```js
assert(

View File

@ -8,59 +8,59 @@ dashedName: sha-1
# --description--
**SHA-1** or **SHA1** is a one-way hash function; it computes a 160-bit message digest.
**SHA-1** 或稱 **SHA1** 是一種單向散列函數,它產生數據的 160 位摘要信息。
SHA-1 often appears in security protocols; for example, many HTTPS websites use RSA with SHA-1 to secure their connections.
SHA-1 經常出現在安全協議中;例如,許多 HTTPS 網站使用 SHA-1 來保護他們的連接。
BitTorrent uses SHA-1 to verify downloads.
BitTorrent 使用 SHA-1 來驗證下載內容。
Git and Mercurial use SHA-1 digests to identify commits.
Git Mercurial 使用 SHA-1 摘要來覈驗提交內容。
A US government standard, [FIPS 180-1](https://rosettacode.org/wiki/SHA-1/FIPS-180-1), defines SHA-1.
美國政府標準 [FIPS 180-1](https://rosettacode.org/wiki/SHA-1/FIPS-180-1) 了定義 SHA-1
# --instructions--
Write a function that returns the SHA-1 message digest for a given string.
寫一個函數返回給定字符串的 SHA-1 消息摘要。
# --hints--
`SHA1` should be a function.
`SHA1` 應該是一個函數。
```js
assert(typeof SHA1 === 'function');
```
`SHA1("abc")` should return a string.
`SHA1("abc")` 應該返回一個字符串。
```js
assert(typeof SHA1('abc') === 'string');
```
`SHA1("abc")` should return `"a9993e364706816aba3e25717850c26c9cd0d89d"`.
`SHA1("abc")` 應該返回 `"a9993e364706816aba3e25717850c26c9cd0d89d"`
```js
assert.equal(SHA1('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d');
```
`SHA1("Rosetta Code")` should return `"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"`.
`SHA1("Rosetta Code")` 應該返回 `"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"`
```js
assert.equal(SHA1('Rosetta Code'), '48c98f7e5a6e736d790ab740dfc3f51a61abe2b5');
```
`SHA1("Hello world")` should return `"7b502c3a1f48c8609ae212cdfb639dee39673f5e"`.
`SHA1("Hello world")` 應該返回 `"7b502c3a1f48c8609ae212cdfb639dee39673f5e"`
```js
assert.equal(SHA1('Hello world'), '7b502c3a1f48c8609ae212cdfb639dee39673f5e');
```
`SHA1("Programming")` should return `"d1a946bf8b2f2a7292c250063ee28989d742cd4b"`.
`SHA1("Programming")` 應該返回 `"d1a946bf8b2f2a7292c250063ee28989d742cd4b"`
```js
assert.equal(SHA1('Programming'), 'd1a946bf8b2f2a7292c250063ee28989d742cd4b');
```
`SHA1("is Awesome")` should return `"6537205da59c72b57ed3881843c2d24103d683a3"`.
`SHA1("is Awesome")` 應該返回 `"6537205da59c72b57ed3881843c2d24103d683a3"`
```js
assert.equal(SHA1('is Awesome'), '6537205da59c72b57ed3881843c2d24103d683a3');

View File

@ -22,7 +22,7 @@ dashedName: build-a-markdown-previewer
**需求 4** 当在具有 `#editor` 属性的元素内输入 GitHub 风格的 markdown 内容时,文本应该以 HTML 的形式,把所键入的内容渲染在具有 `#preview` 属性的元素中(提示:不需要自己解析 Markdown——可以引入一个叫做 Marked 的库来完成这项工作:<https://cdnjs.com/libraries/marked>)。
**需求 5** 当 Markdown 预览器首次加载时,具有 `#editor` 属性的元素内的默认内容应该包含以下每个种类的至少一段有效的 Markdown 代码标题H1 标签、次级标题H2 标签)、链接、行内代码、代码块、列表、引用块、图片、加粗文本。
**需求 5** 当 Markdown 预览器首次加载时,具有 `#editor` 属性的元素内的默认内容应该包含以下每个种类的至少一段有效的 Markdown 代码:标题元素H1 标签)、次级标题元素H2 标签)、链接、行内代码、代码块、列表、引用块、图片、加粗文本。
**需求 6** 当 Markdown 预览器首次加载时,具有 `#editor` 属性的元素内容应该以 HTML 的形式渲染在具有 `#preview` 属性的元素中。

View File

@ -14,67 +14,54 @@ dashedName: access-props-using-this-props
# --instructions--
在父组件 `ResetPassword` 中渲染 `ReturnTempPassword` 组件的一个实例。 在这里, `ReturnTempPassword` 提供一个 `tempPassword` prop并赋值一个长度至少为 8 个字符的字符串。 在子组件 `ReturnTempPassword`,访问 `strong` 标签`tempPassword` prop以确保用户看到临时密码
在父组件 `App` 中渲染 `Welcome` 组件的一个实例。 在这里, `Welcome` 一个 `name` prop给它赋值一个字符串。 在 `Welcome` 的子节点里,访问 `strong` 标签`name` prop
# --hints--
`ResetPassword` 组件应返回单个 `div` 元素。
`App` 组件应返回单个 `div` 元素。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return mockedComponent.children().type() === 'div';
})()
);
```
`ResetPassword`第四个子组件应该是 `ReturnTempPassword` 组件。
`App` 的子组件应该是 `Welcome` 组件。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return (
mockedComponent.children().childAt(3).name() === 'ReturnTempPassword'
mockedComponent.children().childAt(0).name() === 'Welcome'
);
})()
);
```
`ReturnTempPassword` 组件应该有一个名为 `tempPassword` 的属性
`Welcome` 组件应该有一个名为 `name` 的 prop
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
return mockedComponent.find('ReturnTempPassword').props().tempPassword;
const mockedComponent = Enzyme.mount(React.createElement(App));
return mockedComponent.find('Welcome').props().name;
})()
);
```
`ReturnTempPassword` 组件的 `tempPassword` prop 值应该是一个字符串,至少为 8 个字符。
`Welcome` 组件应显示你在 `strong` 标签中作为 `name` 属性传递的字符
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const temp = mockedComponent.find('ReturnTempPassword').props()
.tempPassword;
return typeof temp === 'string' && temp.length >= 8;
})()
);
```
`ReturnTempPassword` 组件应该显示作为 `tempPassword` prop 创建的密码,并且密码被包裹在 `strong` 标签中。
```js
assert(
(function () {
const mockedComponent = Enzyme.mount(React.createElement(ResetPassword));
const mockedComponent = Enzyme.mount(React.createElement(App));
return (
mockedComponent.find('strong').text() ===
mockedComponent.find('ReturnTempPassword').props().tempPassword
mockedComponent.find('Welcome').props().name
);
})()
);
@ -85,13 +72,13 @@ assert(
## --after-user-code--
```jsx
ReactDOM.render(<ResetPassword />, document.getElementById('root'))
ReactDOM.render(<App />, document.getElementById('root'))
```
## --seed-contents--
```jsx
class ReturnTempPassword extends React.Component {
class App extends React.Component {
constructor(props) {
super(props);
@ -100,14 +87,14 @@ class ReturnTempPassword extends React.Component {
return (
<div>
{ /* Change code below this line */ }
<p>Your temporary password is: <strong></strong></p>
<Welcome />
{ /* Change code above this line */ }
</div>
);
}
};
class ResetPassword extends React.Component {
class Welcome extends React.Component {
constructor(props) {
super(props);
@ -115,11 +102,8 @@ class ResetPassword extends React.Component {
render() {
return (
<div>
<h2>Reset Password</h2>
<h3>We've generated a new temporary password for you.</h3>
<h3>Please reset this password from your account settings ASAP.</h3>
{ /* Change code below this line */ }
<p>Hello, <strong></strong>!</p>
{ /* Change code above this line */ }
</div>
);
@ -130,7 +114,7 @@ class ResetPassword extends React.Component {
# --solutions--
```jsx
class ReturnTempPassword extends React.Component {
class Welcome extends React.Component {
constructor(props) {
super(props);
@ -138,13 +122,15 @@ class ReturnTempPassword extends React.Component {
render() {
return (
<div>
<p>Your temporary password is: <strong>{this.props.tempPassword}</strong></p>
{ /* Change code below this line */ }
<p>Hello, <strong>{this.props.name}</strong>!</p>
{ /* Change code above this line */ }
</div>
);
}
};
class ResetPassword extends React.Component {
class App extends React.Component {
constructor(props) {
super(props);
@ -152,11 +138,8 @@ class ResetPassword extends React.Component {
render() {
return (
<div>
<h2>Reset Password</h2>
<h3>We've generated a new temporary password for you.</h3>
<h3>Please reset this password from your account settings ASAP.</h3>
{ /* Change code below this line */ }
<ReturnTempPassword tempPassword="serrPbqrPnzc" />
<Welcome name="Quincy"/>
{ /* Change code above this line */ }
</div>
);

View File

@ -14,7 +14,7 @@ dashedName: compose-react-components
在代码编辑器中,`TypesOfFood` 组件已经渲染了一个名为 `Vegetables` 的组件。 此外,还有上次挑战中的 `Fruits` 组件。
`Fruits` 中嵌套两个组件,首先 `NonCitrus`,然后是 `Citrus` 这两个组件都已经引入。 接下来,将 `Fruits` 类组件嵌到 `TypesOfFood` 组件中,位于 `h1` 标题下方和 `Vegetables` 上方。 结果应该是一系列嵌套的组件,它们使用两种不同的组件类型。
`Fruits` 中嵌套两个组件,首先 `NonCitrus`,然后是 `Citrus` 这两个组件都已经引入。 接下来,将 `Fruits` 类组件嵌`TypesOfFood` 组件中,位于 `h1` 标题元素下方和 `Vegetables` 上方。 结果应该是一系列嵌套的组件,它们使用两种不同的组件类型。
# --hints--

View File

@ -109,7 +109,7 @@ assert(
);
```
`h1`头应该从组件的 state 渲染 `submit` 字段的值。
`h1`题元素应该渲染从组件的状态 `submit` 字段获取的值。
```js
(() => {

View File

@ -38,7 +38,7 @@ class Kitten extends React.Component {
assert(Enzyme.shallow(React.createElement(MyComponent)).type() === 'div');
```
返回的 `div` 中应该渲染一个 `h1` 标题。
返回的 `div` 中应该渲染一个 `h1` 标题元素
```js
assert(
@ -48,7 +48,7 @@ assert(
);
```
`h1` 标题中应该包含字符串 `Hello React!`
`h1` 标题元素中应该包含字符串 `Hello React!`
```js
assert(

View File

@ -27,7 +27,7 @@ assert(
);
```
`MyComponent` 应该在 `div` 中渲染一个 `h1` 标题。
`MyComponent` 应该在 `div` 中渲染一个 `h1` 标题元素
```js
assert(
@ -44,7 +44,7 @@ assert(
assert(/<h1>\n*\s*\{\s*name\s*\}\s*\n*<\/h1>/.test(getUserInput('index')));
```
渲染的 `h1` 标题中应该包含一段文本,这段文本是从组件的 state 中渲染出来的
渲染的 `h1` 标题元素应包含从组件状态渲染的文本
```js
async () => {

View File

@ -33,7 +33,7 @@ assert(
);
```
`MyComponent` 应该在 `div` 中渲染一个 `h1` 标题。
`MyComponent` 应该在 `div` 中渲染一个 `h1` 标题元素
```js
assert(
@ -43,7 +43,7 @@ assert(
);
```
渲染的 `h1` 标题应该只包含一段文本,这段文本是从组件的 state 中渲染出来的
渲染的 `h1` 标题元素应该只包含从组件状态渲染的文本
```js
async () => {

View File

@ -35,13 +35,13 @@ assert(
);
```
`MyComponent` 应该渲染一个 `h1` 标题。
`MyComponent` 应该渲染一个 `h1` 标题元素
```js
assert(Enzyme.mount(React.createElement(MyComponent)).find('h1').length === 1);
```
渲染的 `h1` 标题中应该包含一段文本,这段文本是从组件的 state 中渲染出来的
渲染的 `h1` 标题元素应包含从组件状态渲染的文本
```js
async () => {

View File

@ -77,7 +77,7 @@ assert(
);
```
mixin 应该有一个 `@else if` 语句来检查 `$val` 是否等于 `heavy`,并设置 `border``3px solid black`
mixin 应该有一个 `@else if` 语句来检查 `$val` 是否等于 `heavy`,并设置 `border``6px solid black`
```js
assert(

View File

@ -8,59 +8,59 @@ dashedName: sha-1
# --description--
**SHA-1** or **SHA1** is a one-way hash function; it computes a 160-bit message digest.
**SHA-1** 或称 **SHA1** 是一种单向散列函数,它产生数据的 160 位摘要信息。
SHA-1 often appears in security protocols; for example, many HTTPS websites use RSA with SHA-1 to secure their connections.
SHA-1 经常出现在安全协议中;例如,许多 HTTPS 网站使用 SHA-1 来保护他们的连接。
BitTorrent uses SHA-1 to verify downloads.
BitTorrent 使用 SHA-1 来验证下载内容。
Git and Mercurial use SHA-1 digests to identify commits.
Git Mercurial 使用 SHA-1 摘要来核验提交内容。
A US government standard, [FIPS 180-1](https://rosettacode.org/wiki/SHA-1/FIPS-180-1), defines SHA-1.
美国政府标准 [FIPS 180-1](https://rosettacode.org/wiki/SHA-1/FIPS-180-1) 了定义 SHA-1
# --instructions--
Write a function that returns the SHA-1 message digest for a given string.
写一个函数返回给定字符串的 SHA-1 消息摘要。
# --hints--
`SHA1` should be a function.
`SHA1` 应该是一个函数。
```js
assert(typeof SHA1 === 'function');
```
`SHA1("abc")` should return a string.
`SHA1("abc")` 应该返回一个字符串。
```js
assert(typeof SHA1('abc') === 'string');
```
`SHA1("abc")` should return `"a9993e364706816aba3e25717850c26c9cd0d89d"`.
`SHA1("abc")` 应该返回 `"a9993e364706816aba3e25717850c26c9cd0d89d"`
```js
assert.equal(SHA1('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d');
```
`SHA1("Rosetta Code")` should return `"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"`.
`SHA1("Rosetta Code")` 应该返回 `"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"`
```js
assert.equal(SHA1('Rosetta Code'), '48c98f7e5a6e736d790ab740dfc3f51a61abe2b5');
```
`SHA1("Hello world")` should return `"7b502c3a1f48c8609ae212cdfb639dee39673f5e"`.
`SHA1("Hello world")` 应该返回 `"7b502c3a1f48c8609ae212cdfb639dee39673f5e"`
```js
assert.equal(SHA1('Hello world'), '7b502c3a1f48c8609ae212cdfb639dee39673f5e');
```
`SHA1("Programming")` should return `"d1a946bf8b2f2a7292c250063ee28989d742cd4b"`.
`SHA1("Programming")` 应该返回 `"d1a946bf8b2f2a7292c250063ee28989d742cd4b"`
```js
assert.equal(SHA1('Programming'), 'd1a946bf8b2f2a7292c250063ee28989d742cd4b');
```
`SHA1("is Awesome")` should return `"6537205da59c72b57ed3881843c2d24103d683a3"`.
`SHA1("is Awesome")` 应该返回 `"6537205da59c72b57ed3881843c2d24103d683a3"`
```js
assert.equal(SHA1('is Awesome'), '6537205da59c72b57ed3881843c2d24103d683a3');

View File

@ -1,6 +1,6 @@
---
id: 589690e6f9fc0f352b528e6e
title: Clean Up Your Project with Modules
title: Limpia tu proyecto con módulos
challengeType: 2
forumTopicId: 301549
dashedName: clean-up-your-project-with-modules
@ -8,9 +8,9 @@ dashedName: clean-up-your-project-with-modules
# --description--
Right now, everything you have is in your `server.js` file. This can lead to hard to manage code that isn't very expandable. Create 2 new files: `routes.js` and `auth.js`
Ahora mismo, todo lo que tienes está en tu archivo `server.js`. Esto puede dar lugar a un código difícil de gestionar y poco ampliable. Crea 2 nuevos archivos: `routes.js` y `auth.js`
Both should start with the following code:
Ambos deben comenzar con el siguiente código:
```js
module.exports = function (app, myDataBase) {
@ -18,19 +18,19 @@ module.exports = function (app, myDataBase) {
}
```
Now, in the top of your server file, require these files like so: `const routes = require('./routes.js');` Right after you establish a successful connection with the database, instantiate each of them like so: `routes(app, myDataBase)`
Ahora, en la parte superior de tu archivo de servidor, requiere estos archivos así: `const routes = require('./routes.js');` Justo después de establecer una conexión exitosa con la base de datos, instancia cada uno de ellos así: `routes(app, myDataBase)`
Finally, take all of the routes in your server and paste them into your new files, and remove them from your server file. Also take the `ensureAuthenticated` function, since it was specifically created for routing. Now, you will have to correctly add the dependencies in which are used, such as `const passport = require('passport');`, at the very top, above the export line in your `routes.js` file.
Finalmente, toma todas las rutas de tu servidor y pégalas en tus nuevos archivos, y elimínalas de tu archivo del servidor. También toma la función `ensureAuthenticated` ya que fue específicamente creada para enrutamiento. Ahora, tendrás que agregar correctamente las dependencias en las que se utilizan, como `const passport = require('passport');`, en la parte superior, encima de la línea de exportación en tu archivo `routes.js`.
Keep adding them until no more errors exist, and your server file no longer has any routing (**except for the route in the catch block**)!
Sigue agregándolos hasta que no existan más errores, y tu archivo de servidor ya no tenga ninguna ruta ¡(**excepto la ruta en el bloque catch**)!
Now do the same thing in your auth.js file with all of the things related to authentication such as the serialization and the setting up of the local strategy and erase them from your server file. Be sure to add the dependencies in and call `auth(app, myDataBase)` in the server in the same spot.
Ahora haz lo mismo en tu archivo auth.js con todas las cosas relacionadas con la autenticación como la serialización y la configuración de la estrategia local y bórralas de tu archivo del servidor. Asegúrate de agregar las dependencias y llamar a `auth(app, myDataBase)` en el servidor en el mismo lugar.
Submit your page when you think you've got it right. If you're running into errors, you can check out an example of the completed project [here](https://gist.github.com/camperbot/2d06ac5c7d850d8cf073d2c2c794cc92).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar un ejemplo del proyecto completado [aquí](https://gist.github.com/camperbot/2d06ac5c7d850d8cf073d2c2c794cc92).
# --hints--
Modules should be present.
Los módulos deben estar presentes.
```js
(getUserInput) =>

View File

@ -1,6 +1,6 @@
---
id: 589fc831f9fc0f352b528e75
title: Communicate by Emitting
title: Comunicarse por emisión
challengeType: 2
forumTopicId: 301550
dashedName: communicate-by-emitting
@ -8,27 +8,27 @@ dashedName: communicate-by-emitting
# --description--
<dfn>Emit</dfn> is the most common way of communicating you will use. When you emit something from the server to 'io', you send an event's name and data to all the connected sockets. A good example of this concept would be emitting the current count of connected users each time a new user connects!
<dfn>Emit</dfn> es la forma más común de comunicación que utilizarás. Cuando se emite algo desde el servidor a 'io', se envía el nombre y los datos de un evento a todos los sockets conectados. ¡Un buen ejemplo de este concepto sería emitir el recuento actual de usuarios conectados cada vez que se conecte un nuevo usuario!
Start by adding a variable to keep track of the users, just before where you are currently listening for connections.
Comienza añadiendo una variable para llevar la cuenta de los usuarios, justo antes de donde estás escuchando las conexiones.
```js
let currentUsers = 0;
```
Now, when someone connects, you should increment the count before emitting the count. So, you will want to add the incrementer within the connection listener.
Ahora, cuando alguien se conecte, deberás incrementar la cuenta antes de emitirla. Por lo tanto, querrá añadir el incrementador dentro del oyente de la conexión.
```js
++currentUsers;
```
Finally, after incrementing the count, you should emit the event (still within the connection listener). The event should be named 'user count', and the data should just be the `currentUsers`.
Por último, después de incrementar el recuento, debes emitir el evento (todavía dentro del oyente de la conexión). El evento debe llamarse 'user count', y los datos deben ser simplemente los `currentUsers`.
```js
io.emit('user count', currentUsers);
```
Now, you can implement a way for your client to listen for this event! Similar to listening for a connection on the server, you will use the `on` keyword.
Ahora, ¡puedes implementar una manera para que tu cliente escuche este evento! De forma similar a la escucha de una conexión en el servidor, utilizarás la palabra clave `on`.
```js
socket.on('user count', function(data) {
@ -36,13 +36,13 @@ socket.on('user count', function(data) {
});
```
Now, try loading up your app, authenticate, and you should see in your client console '1' representing the current user count! Try loading more clients up, and authenticating to see the number go up.
Ahora, ¡intenta cargar tu aplicación, autentifica, y debes ver en tu consola "1" que representa el recuento de usuarios actual! Trata de cargar más clientes y de autentificar para ver cómo sube el número.
Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point [here](https://gist.github.com/camperbot/28ef7f1078f56eb48c7b1aeea35ba1f5).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/28ef7f1078f56eb48c7b1aeea35ba1f5).
# --hints--
currentUsers should be defined.
currentUsers deben ser definidos.
```js
(getUserInput) =>
@ -60,7 +60,7 @@ currentUsers should be defined.
);
```
Server should emit the current user count at each new connection.
El servidor debe emitir el recuento actual de usuarios en cada nueva conexión.
```js
(getUserInput) =>
@ -78,7 +78,7 @@ Server should emit the current user count at each new connection.
);
```
Your client should be listening for 'user count' event.
Tu cliente debe estar escuchando el evento 'user count'.
```js
(getUserInput) =>

View File

@ -1,6 +1,6 @@
---
id: 5895f70df9fc0f352b528e6a
title: Create New Middleware
title: Crea nuevo Middleware
challengeType: 2
forumTopicId: 301551
dashedName: create-new-middleware
@ -8,9 +8,9 @@ dashedName: create-new-middleware
# --description--
As is, any user can just go to `/profile` whether they have authenticated or not, by typing in the url. We want to prevent this, by checking if the user is authenticated first before rendering the profile page. This is the perfect example of when to create a middleware.
Tal como está, cualquier usuario puede ir a `/profile` si se ha autentificado o no, escribiendo la url. Queremos evitar esto, comprobando si el usuario está autentificado primero antes de mostrar la página de perfil. Este es el ejemplo perfecto de cuándo crear un middleware.
The challenge here is creating the middleware function `ensureAuthenticated(req, res, next)`, which will check if a user is authenticated by calling passport's `isAuthenticated` method on the `request` which, in turn, checks if `req.user` is defined. If it is, then `next()` should be called, otherwise, we can just respond to the request with a redirect to our homepage to login. An implementation of this middleware is:
El desafío aquí es crear la función middleware `ensureAuthenticated(req, res, next)`, el cual comprobará si un usuario está autentificado llamando al método `isAuthenticated` del pasaporte en la `request` que, a su vez, comprueba si `req.user` está definido. Si lo es, entonces se debe llamar a `next()`, de lo contrario, podemos simplemente responder a la solicitud con una redirección a nuestra página de inicio para iniciar sesión. Una implementación de este middleware es:
```js
function ensureAuthenticated(req, res, next) {
@ -21,7 +21,7 @@ function ensureAuthenticated(req, res, next) {
};
```
Now add *ensureAuthenticated* as a middleware to the request for the profile page before the argument to the get request containing the function that renders the page.
Ahora añade *ensureAuthenticated* como middleware a la petición de la página de perfil antes del argumento de la petición get que contiene la función que renderiza la página.
```js
app
@ -31,11 +31,11 @@ app
});
```
Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point [here](https://gist.github.com/camperbot/ae49b8778cab87e93284a91343da0959).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/ae49b8778cab87e93284a91343da0959).
# --hints--
Middleware ensureAuthenticated should be implemented and on our /profile route.
El Middleware ensureAuthenticated debe ser implementado y en nuestra ruta /profile.
```js
(getUserInput) =>
@ -58,7 +58,7 @@ Middleware ensureAuthenticated should be implemented and on our /profile route.
);
```
A Get request to /profile should correctly redirect to / since we are not authenticated.
Una petición Get a /profile debe redirigir correctamente a / ya que no estamos autentificados.
```js
(getUserInput) =>

View File

@ -1,6 +1,6 @@
---
id: 5900f4771000cf542c50ff89
title: 'Problem 266: Pseudo Square Root'
title: 'Problema 266: Pseudorraiz quadrada'
challengeType: 5
forumTopicId: 301915
dashedName: problem-266-pseudo-square-root
@ -8,22 +8,22 @@ dashedName: problem-266-pseudo-square-root
# --description--
The divisors of 12 are: 1,2,3,4,6 and 12.
Os divisores de 12 são: 1, 2, 3, 4, 6 e 12.
The largest divisor of 12 that does not exceed the square root of 12 is 3.
O maior divisor de 12 que não excede a raiz quadrada de 12 é 3.
We shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of n.
Vamos chamar o maior divisor de um inteiro $n$ que não excede a raiz quadrada de $n$ como a pseudorraiz quadrada ($PSR$) de $n$.
It can be seen that PSR(3102)=47.
Podemos ver que $PSR(3102) = 47$.
Let p be the product of the primes below 190. Find PSR(p) mod 1016.
Considere $p$ como o produto dos números primos abaixo de 190. Encontre $PSR(p)\bmod {10}^{16}$.
# --hints--
`euler266()` should return 1096883702440585.
`pseudoSquareRoot()` deve retornar `1096883702440585`.
```js
assert.strictEqual(euler266(), 1096883702440585);
assert.strictEqual(pseudoSquareRoot(), 1096883702440585);
```
# --seed--
@ -31,12 +31,12 @@ assert.strictEqual(euler266(), 1096883702440585);
## --seed-contents--
```js
function euler266() {
function pseudoSquareRoot() {
return true;
}
euler266();
pseudoSquareRoot();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4771000cf542c50ff8a
title: 'Problem 267: Billionaire'
title: 'Problema 267: Bilionário'
challengeType: 5
forumTopicId: 301916
dashedName: problem-267-billionaire
@ -8,24 +8,24 @@ dashedName: problem-267-billionaire
# --description--
You are given a unique investment opportunity.
Você recebe uma oportunidade única de investimento.
Starting with £1 of capital, you can choose a fixed proportion, f, of your capital to bet on a fair coin toss repeatedly for 1000 tosses.
Começando com £1 do capital, você pode escolher uma proporção fixa, $f$, do seu capital para apostar em uma moeda justa repetidamente por 1000 lançamentos.
Your return is double your bet for heads and you lose your bet for tails.
Seu retorno é o dobro da sua aposta para cara e você perde a aposta para coroa.
For example, if f = 1/4, for the first toss you bet £0.25, and if heads comes up you win £0.5 and so then have £1.5. You then bet £0.375 and if the second toss is tails, you have £1.125.
Por exemplo, se $f = \frac{1}{4}$, para o primeiro lançamento, você aposta £0,25. Se cara aparecer, você ganha £0,5 e passa a ter £1,5. Você aposta £0,375 e, se o segundo lançamento for coroa, terá £1,125.
Choosing f to maximize your chances of having at least £1,000,000,000 after 1,000 flips, what is the chance that you become a billionaire?
Escolhendo $f$ para maximizar suas chances de ter pelo menos £1.000.000.000 depois de 1.000 lançamentos da moeda, qual é a chance de você se tornar um bilionário?
All computations are assumed to be exact (no rounding), but give your answer rounded to 12 digits behind the decimal point in the form 0.abcdefghijkl.
Todos os cálculos devem ser exatos (sem arredondamento), mas sua resposta deve ser arredondada para 12 algarismos depois da vírgula na forma 0.abcdefghijkl.
# --hints--
`euler267()` should return 0.999992836187.
`billionaire()` deve retornar `0.999992836187`.
```js
assert.strictEqual(euler267(), 0.999992836187);
assert.strictEqual(billionaire(), 0.999992836187);
```
# --seed--
@ -33,12 +33,12 @@ assert.strictEqual(euler267(), 0.999992836187);
## --seed-contents--
```js
function euler267() {
function billionaire() {
return true;
}
euler267();
billionaire();
```
# --solutions--

View File

@ -1,7 +1,7 @@
---
id: 5900f4791000cf542c50ff8b
title: >-
Problem 268: Counting numbers with at least four distinct prime factors less than 100
Problema 268: Contagem de números com pelo menos quatro divisores primos distintos menores que 100
challengeType: 5
forumTopicId: 301917
dashedName: >-
@ -10,16 +10,16 @@ dashedName: >-
# --description--
It can be verified that there are 23 positive integers less than 1000 that are divisible by at least four distinct primes less than 100.
É possível verificar que há 23 números inteiros positivos inferiores a 1000 que são divisíveis por, pelo menos, quatro números primos distintos inferiores a 100.
Find how many positive integers less than 1016 are divisible by at least four distinct primes less than 100.
Encontre quantos números inteiros positivos inferiores a ${10}^{16}$ que são divisíveis por, pelo menos, quatro números primos distintos inferiores a 100.
# --hints--
`euler268()` should return 785478606870985.
`fourDistinctPrimeFactors()` deve retornar `785478606870985`.
```js
assert.strictEqual(euler268(), 785478606870985);
assert.strictEqual(fourDistinctPrimeFactors(), 785478606870985);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler268(), 785478606870985);
## --seed-contents--
```js
function euler268() {
function fourDistinctPrimeFactors() {
return true;
}
euler268();
fourDistinctPrimeFactors();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4791000cf542c50ff8c
title: 'Problem 269: Polynomials with at least one integer root'
title: 'Problema 269: Polinômios com pelo menos uma raiz inteira'
challengeType: 5
forumTopicId: 301918
dashedName: problem-269-polynomials-with-at-least-one-integer-root
@ -8,24 +8,30 @@ dashedName: problem-269-polynomials-with-at-least-one-integer-root
# --description--
A root or zero of a polynomial P(x) is a solution to the equation P(x) = 0.
Uma raiz ou zero de um polinômio $P(x)$ é uma solução para a equação $P(x) = 0$.
Define Pn as the polynomial whose coefficients are the digits of n.
Defina $P_n$ como o polinômio cujos coeficientes são os algarismos de $n$.
For example, P5703(x) = 5x3 + 7x2 + 3.
Por exemplo, $P_{5703}(x) = 5x^3 + 7x^2 + 3$.
We can see that:Pn(0) is the last digit of n, Pn(1) is the sum of the digits of n, Pn(10) is n itself.Define Z(k) as the number of positive integers, n, not exceeding k for which the polynomial Pn has at least one integer root.
Podemos ver que:
It can be verified that Z(100 000) is 14696.
- $P_n(0)$ é o último algarismo de $n$,
- $P_n(1)$ é a soma dos algarismos de $n$,
- $Pn(10)$ é o próprio $n$.
What is Z(1016)?
Defina $Z(k)$ como a quantidade de números inteiros positivos, $n$, sem exceder $k$, para a qual o polinômio $P_n$ tem pelo menos uma raiz inteira.
Podemos verificar que $Z(100.000)$ é 14696.
Qual é a $Z({10}^{16})$?
# --hints--
`euler269()` should return 1311109198529286.
`polynomialsWithOneIntegerRoot()` deve retornar `1311109198529286`.
```js
assert.strictEqual(euler269(), 1311109198529286);
assert.strictEqual(polynomialsWithOneIntegerRoot(), 1311109198529286);
```
# --seed--
@ -33,12 +39,12 @@ assert.strictEqual(euler269(), 1311109198529286);
## --seed-contents--
```js
function euler269() {
function polynomialsWithOneIntegerRoot() {
return true;
}
euler269();
polynomialsWithOneIntegerRoot();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f47c1000cf542c50ff8e
title: 'Problem 270: Cutting Squares'
title: 'Problema 270: Corte dos quadrados'
challengeType: 5
forumTopicId: 301920
dashedName: problem-270-cutting-squares
@ -8,24 +8,24 @@ dashedName: problem-270-cutting-squares
# --description--
A square piece of paper with integer dimensions N×N is placed with a corner at the origin and two of its sides along the x- and y-axes. Then, we cut it up respecting the following rules:
Um pedaço de papel quadrado com dimensões inteiras $N×N$ é colocado com um canto na origem e dois de seus lados ao longo dos eixos $x$ e $y$. Depois, cortamos os quadrados respeitando as seguintes regras:
We only make straight cuts between two points lying on different sides of the square, and having integer coordinates.
- Fazemos apenas cortes retos entre dois pontos que estejam em lados diferentes do quadrado e que tenham como coordenadas números inteiros.
- Dois cortes não podem se cruzar, mas vários cortes podem se encontrar no mesmo ponto das arestas.
- Prosseguimos até que não seja possível fazer mais cortes.
Two cuts cannot cross, but several cuts can meet at the same border point.
Contando quaisquer reflexões ou rotações distintas, chamamos de $C(N)$ o número de maneiras de cortar um quadrado $N×N$. Por exemplo, $C(1) = 2$ e $C(2) = 30$ (mostrados abaixo).
Proceed until no more legal cuts can be made.
<img class="img-responsive center-block" alt="maneiras de cortar o quadrado 2x2, contando reflexões e rotações como distintas" src="https://cdn.freecodecamp.org/curriculum/project-euler/cutting-squares.gif" style="background-color: white; padding: 10px;" />
Counting any reflections or rotations as distinct, we call C(N) the number of ways to cut an N×N square. For example, C(1) = 2 and C(2) = 30 (shown below).
What is C(30) mod 108 ?
Qual é o $C(30)\bmod {10}^8$ ?
# --hints--
`euler270()` should return 82282080.
`cuttingSquares()` deve retornar `82282080`.
```js
assert.strictEqual(euler270(), 82282080);
assert.strictEqual(cuttingSquares(), 82282080);
```
# --seed--
@ -33,12 +33,12 @@ assert.strictEqual(euler270(), 82282080);
## --seed-contents--
```js
function euler270() {
function cuttingSquares() {
return true;
}
euler270();
cuttingSquares();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f47b1000cf542c50ff8d
title: 'Problem 271: Modular Cubes, part 1'
title: 'Problema 271: Cubos modulares, parte 1'
challengeType: 5
forumTopicId: 301921
dashedName: problem-271-modular-cubes-part-1
@ -8,18 +8,18 @@ dashedName: problem-271-modular-cubes-part-1
# --description--
For a positive number n, define S(n) as the sum of the integers x, for which 1
Para um número positivo $n$, defina $S(n)$ como a soma dos números inteiros $x$, para a qual $1 < x < n$ e $x^3 \equiv 1\bmod n$.
When n=91, there are 8 possible values for x, namely : 9, 16, 22, 29, 53, 74, 79, 81. Thus, S(91)=9+16+22+29+53+74+79+81=363.
Quando $n = 91$, existem 8 valores possíveis $x$: 9, 16, 22, 29, 53, 74, 79 e 81. Portanto, $S(91) = 9 + 16 + 22 + 29 + 53 + 74 + 79 + 81 = 363$.
Find S(13082761331670030).
Encontre $S(13.082.761.331.670.030)$.
# --hints--
`euler271()` should return 4617456485273130000.
`modularCubesOne()` deve retornar `4617456485273130000`.
```js
assert.strictEqual(euler271(), 4617456485273130000);
assert.strictEqual(modularCubesOne(), 4617456485273130000);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler271(), 4617456485273130000);
## --seed-contents--
```js
function euler271() {
function modularCubesOne() {
return true;
}
euler271();
modularCubesOne();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f47d1000cf542c50ff8f
title: 'Problem 272: Modular Cubes, part 2'
title: 'Problema 272: Cubos modulares, parte 2'
challengeType: 5
forumTopicId: 301922
dashedName: problem-272-modular-cubes-part-2
@ -8,18 +8,18 @@ dashedName: problem-272-modular-cubes-part-2
# --description--
For a positive number n, define C(n) as the number of the integers x, for which 1
Para um número positivo $n$, defina $C(n)$ como a quantidade de números inteiros $x$, para a qual $1 < x < n$ e $x^3 \equiv 1\bmod n$.
When n=91, there are 8 possible values for x, namely : 9, 16, 22, 29, 53, 74, 79, 81. Thus, C(91)=8.
Quando $n = 91$, existem 8 valores possíveis $x$: 9, 16, 22, 29, 53, 74, 79 e 81. Assim, $C(91) = 8$.
Find the sum of the positive numbers n≤1011 for which C(n)=242.
Encontre a soma dos números positivos $n {10}^{11}$ para a qual $C(n)=242$.
# --hints--
`euler272()` should return 8495585919506151000.
`modularCubesTwo()` deve retornar `8495585919506151000`.
```js
assert.strictEqual(euler272(), 8495585919506151000);
assert.strictEqual(modularCubesTwo(), 8495585919506151000);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler272(), 8495585919506151000);
## --seed-contents--
```js
function euler272() {
function modularCubesTwo() {
return true;
}
euler272();
modularCubesTwo();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f47e1000cf542c50ff90
title: 'Problem 273: Sum of Squares'
title: 'Problema 273: Soma dos quadrados'
challengeType: 5
forumTopicId: 301923
dashedName: problem-273-sum-of-squares
@ -8,16 +8,24 @@ dashedName: problem-273-sum-of-squares
# --description--
Consider equations of the form: a2 + b2 = N, 0 ≤ a ≤ b, a, b and N integer.
Considere as equações da forma: $a^2 + b^2 = N$, $0 ≤ a ≤ b$, sendo $a$, $b$ e $N$ números inteiros.
For N=65 there are two solutions: a=1, b=8 and a=4, b=7. We call S(N) the sum of the values of a of all solutions of a2 + b2 = N, 0 ≤ a ≤ b, a, b and N integer. Thus S(65) = 1 + 4 = 5. Find ∑S(N), for all squarefree N only divisible by primes of the form 4k+1 with 4k+1 &lt; 150.
Para $N = 65$, existem duas soluções:
$a = 1, b = 8$ e $a = 4, b = 7$.
Chamamos de $S(N)$ a soma dos valores de $a$ de todas as soluções de $a^2 + b^2 = N$, $0 ≤ a ≤ b$, sendo $a$, $b$ e $N$ números inteiros.
Portanto, $S(65) = 1 + 4 = 5$.
Encontre $\sum S(N)$, para todos os $N$ sem quadrados, divisíveis apenas por números primos da forma $4k + 1$, com $4k + 1 &lt; 150$.
# --hints--
`euler273()` should return 2032447591196869000.
`sumOfSquares()` deve retornar `2032447591196869000`.
```js
assert.strictEqual(euler273(), 2032447591196869000);
assert.strictEqual(sumOfSquares(), 2032447591196869000);
```
# --seed--
@ -25,12 +33,12 @@ assert.strictEqual(euler273(), 2032447591196869000);
## --seed-contents--
```js
function euler273() {
function sumOfSquares() {
return true;
}
euler273();
sumOfSquares();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f47f1000cf542c50ff91
title: 'Problem 274: Divisibility Multipliers'
title: 'Problema 274: Multiplicadores de divisibilidade'
challengeType: 5
forumTopicId: 301924
dashedName: problem-274-divisibility-multipliers
@ -8,26 +8,28 @@ dashedName: problem-274-divisibility-multipliers
# --description--
For each integer p > 1 coprime to 10 there is a positive divisibility multiplier m &lt; p which preserves divisibility by p for the following function on any positive integer, n:
Para cada número inteiro $p > 1$ coprimo de 10, há um multiplicador positivo de divisibilidade $m &lt; p$ que preserva a divisibilidade por $p$ para a seguinte função em qualquer número inteiro positivo, $n$:
f(n) = (all but the last digit of n) + (the last digit of n) \* m
$f(n) = (\text{todos exceto o último algarismo de} \\; n) + (\text{o último algarismo de} \\; n) \times m$
That is, if m is the divisibility multiplier for p, then f(n) is divisible by p if and only if n is divisible by p.
Ou seja, se $m$ for o multiplicador de divisibilidade para $p$, então $f(n)$ é divisível por $p$ se e somente se $n$ for divisível por $p$.
(When n is much larger than p, f(n) will be less than n and repeated application of f provides a multiplicative divisibility test for p.)
Quando $n$ for muito maior que $p$, $f(n)$ será menor que $n$ e a aplicação repetida de $f$ fornecerá um teste de multiplicador de divisibilidade para $p$.
For example, the divisibility multiplier for 113 is 34.
Por exemplo, o multiplicador de divisibilidade para 113 é 34.
f(76275) = 7627 + 5 *34 = 7797 : 76275 and 7797 are both divisible by 113f(12345) = 1234 + 5* 34 = 1404 : 12345 and 1404 are both not divisible by 113
$f(76275) = 7627 + 5 \times 34 = 7797$: 76275 e 7797 são divisíveis por 113
The sum of the divisibility multipliers for the primes that are coprime to 10 and less than 1000 is 39517. What is the sum of the divisibility multipliers for the primes that are coprime to 10 and less than 107?
$f(12345) = 1234 + 5 \times 34 = 1404$: 12345 e 1404 não são divisíveis por 113
A soma dos multiplicadores de divisibilidade dos números primos que são coprimos de 10 e menores que 1000 é 39517. Qual é a soma dos multiplicadores de divisibilidade dos números primos que são coprimos de 10 e menores que ${10}^7$?
# --hints--
`euler274()` should return 1601912348822.
`divisibilityMultipliers()` deve retornar `1601912348822`.
```js
assert.strictEqual(euler274(), 1601912348822);
assert.strictEqual(divisibilityMultipliers(), 1601912348822);
```
# --seed--
@ -35,12 +37,12 @@ assert.strictEqual(euler274(), 1601912348822);
## --seed-contents--
```js
function euler274() {
function divisibilityMultipliers() {
return true;
}
euler274();
divisibilityMultipliers();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4801000cf542c50ff92
title: 'Problem 275: Balanced Sculptures'
title: 'Problema 275: Esculturas balanceadas'
challengeType: 5
forumTopicId: 301925
dashedName: problem-275-balanced-sculptures
@ -8,26 +8,27 @@ dashedName: problem-275-balanced-sculptures
# --description--
Let us define a balanced sculpture of order n as follows:
Vamos definir uma escultura balanceada de ordem $n$ da seguinte forma:
A polyomino made up of n+1 tiles known as the blocks (n tiles) and the plinth (remaining tile);
- Um poliminó composto por $n + 1$ blocos, sendo que $n$ são os "blocos" e o bloco restante (+1) é o "pedestal";
- o pedestal tem seu centro na posição ($x = 0$, $y = 0$);
- os blocos têm coordenadas $y$ maiores que zero (portanto o pedestal é o único bloco inferior);
- o centro de massa de todos os blocos, combinados, tem a coordenada $x$ igual a zero.
the plinth has its centre at position (x = 0, y = 0);
Ao contar as esculturas, todos os arranjos que são simplesmente reflexões sobre o eixo $y$, <u>não</u> são contados como distintos. Por exemplo, as 18 esculturas equilibradas de ordem 6 são mostradas abaixo. Observe que cada par de imagens espelhadas (sobre o eixo $y$) é contado como uma escultura:
the blocks have y-coordinates greater than zero (so the plinth is the unique lowest tile);
<img class="img-responsive center-block" alt="18 esculturas balanceadas da ordem de 6" src="https://cdn.freecodecamp.org/curriculum/project-euler/balanced-sculptures.gif" style="background-color: white; padding: 10px;" />
the centre of mass of all the blocks, combined, has x-coordinate equal to zero.
Existem 964 esculturas equilibradas da ordem de 10 e 360505 da ordem de 15.
When counting the sculptures, any arrangements which are simply reflections about the y-axis, are not counted as distinct. For example, the 18 balanced sculptures of order 6 are shown below; note that each pair of mirror images (about the y-axis) is counted as one sculpture:
There are 964 balanced sculptures of order 10 and 360505 of order 15.How many balanced sculptures are there of order 18?
Quantas esculturas equilibradas existem na ordem de 18?
# --hints--
`euler275()` should return 15030564.
`balancedSculptures()` deve retornar `15030564`.
```js
assert.strictEqual(euler275(), 15030564);
assert.strictEqual(balancedSculptures(), 15030564);
```
# --seed--
@ -35,12 +36,12 @@ assert.strictEqual(euler275(), 15030564);
## --seed-contents--
```js
function euler275() {
function balancedSculptures() {
return true;
}
euler275();
balancedSculptures();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4811000cf542c50ff94
title: 'Problem 277: A Modified Collatz sequence'
title: 'Problema 277: Uma sequência de Collatz modificada'
challengeType: 5
forumTopicId: 301927
dashedName: problem-277-a-modified-collatz-sequence
@ -8,28 +8,32 @@ dashedName: problem-277-a-modified-collatz-sequence
# --description--
A modified Collatz sequence of integers is obtained from a starting value a1 in the following way:
Uma sequência de Collatz modificada de inteiros é obtida a partir do valor inicial $a_1$ da seguinte forma:
an+1 = an/3 if an is divisible by 3. We shall denote this as a large downward step, "D".
$a_{n + 1} = \frac{a_n}{3}$ se $a_n$ for divisível por 3. Vamos apresentar isto como um grande passo descendente, "D".
an+1 = (4an + 2)/3 if an divided by 3 gives a remainder of 1. We shall denote this as an upward step, "U".
$a_{n + 1} = \frac{4a_n + 2}{3}$ se $a_n$ dividido por 3 dá resto 1. Vamos apresentar isto como um grande passo ascendente, "U".
an+1 = (2an - 1)/3 if an divided by 3 gives a remainder of 2. We shall denote this as a small downward step, "d".
$a_{n + 1} = \frac{2a_n - 1}{3}$ se $a_n$ dividido por 3 tem 2 como resto. Vamos apresentar isto como um pequeno passo descendente, "d".
The sequence terminates when some an = 1.
A sequência termina quando algum $a_n = 1$.
Given any integer, we can list out the sequence of steps. For instance if a1=231, then the sequence {an}={231,77,51,17,11,7,10,14,9,3,1} corresponds to the steps "DdDddUUdDD".
Dado qualquer número inteiro, podemos listar a sequência de passos. Por exemplo, se $a_1 = 231$, então a sequência $\\{a_n\\} = \\{231, 77, 51, 17, 11, 7, 10, 14, 9, 3, 1\\}$ corresponde aos passos "DdDddUUdDD".
Of course, there are other sequences that begin with that same sequence "DdDddUUdDD....". For instance, if a1=1004064, then the sequence is DdDddUUdDDDdUDUUUdDdUUDDDUdDD. In fact, 1004064 is the smallest possible a1 > 106 that begins with the sequence DdDddUUdDD.
Claro, há outras sequências que começam com a mesma sequência "DdDUUdD...".
What is the smallest a1 > 1015 that begins with the sequence "UDDDUdddDDUDDddDdDddDDUDDdUUDd"?
Por exemplo, se $a_1 = 1004064$, então a sequência será DdDddUUdDDDdUDUUUdDdUUDDDUdDD.
Na verdade, 1004064 é o menor número possível $a_1 > {10}^6$ que começa com a sequência DdDddUUdDD.
Qual é o menor número $a_1 > {10}^{15}$ que começa com a sequência "UDDDUdddDDUDDddDdDddDDUDDdUUDd"?
# --hints--
`euler277()` should return 1125977393124310.
`modifiedCollatzSequence()` deve retornar `1125977393124310`.
```js
assert.strictEqual(euler277(), 1125977393124310);
assert.strictEqual(modifiedCollatzSequence(), 1125977393124310);
```
# --seed--
@ -37,12 +41,12 @@ assert.strictEqual(euler277(), 1125977393124310);
## --seed-contents--
```js
function euler277() {
function modifiedCollatzSequence() {
return true;
}
euler277();
modifiedCollatzSequence();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4831000cf542c50ff95
title: 'Problem 278: Linear Combinations of Semiprimes'
title: 'Problema 278: Combinações lineares de semiprimos'
challengeType: 5
forumTopicId: 301928
dashedName: problem-278-linear-combinations-of-semiprimes
@ -8,20 +8,20 @@ dashedName: problem-278-linear-combinations-of-semiprimes
# --description--
Given the values of integers 1 &lt; a1 &lt; a2 &lt;... &lt; an, consider the linear combination q1a1 + q2a2 + ... + qnan = b, using only integer values qk ≥ 0.
Dados os valores de números inteiros $1 &lt; a_1 &lt; a_2 &lt; \ldots &lt; a_n$, considere a combinação linear $q_1a_1 + q_2a_2 + \ldots + q_na_n = b$, usando somente valores em números inteiros $q_k ≥ 0$.
Note that for a given set of ak, it may be that not all values of b are possible. For instance, if a1 = 5 and a2 = 7, there are no q1 ≥ 0 and q2 ≥ 0 such that b could be 1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18 or 23.
Observe que, para um determinado conjunto de $a_k$, pode ser que nem todos os valores de $b$ sejam possíveis. Por exemplo, se $a_1 = 5$ e $a_2 = 7$, não existem $q_1 ≥ 0$ e $q_2 ≥ 0$ tal que $b$ possa ser 1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18 ou 23.
In fact, 23 is the largest impossible value of b for a1 = 5 and a2 = 7. We therefore call f(5, 7) = 23. Similarly, it can be shown that f(6, 10, 15)=29 and f(14, 22, 77) = 195.
De fato, 23 é o maior valor impossível de $b$ para $a_1 = 5$ e $a_2 = 7$. Portanto, consideramos $f(5, 7) = 23$. Da mesma forma, pode ser mostrado que $f(6, 10, 15)=29$ e $f(14, 22, 77) = 195$.
Find ∑ f(p*q,p*r,q\*r), where p, q and r are prime numbers and p &lt; q &lt; r &lt; 5000.
Encontre $\sum f(pq,pr,qr)$, onde $p$, $q$ e $r$ são números primos e $p &lt; q &lt; r &lt; 5000$.
# --hints--
`euler278()` should return 1228215747273908500.
`linearCombinationOfSemiprimes()` deve retornar `1228215747273908500`.
```js
assert.strictEqual(euler278(), 1228215747273908500);
assert.strictEqual(linearCombinationOfSemiprimes(), 1228215747273908500);
```
# --seed--
@ -29,12 +29,12 @@ assert.strictEqual(euler278(), 1228215747273908500);
## --seed-contents--
```js
function euler278() {
function linearCombinationOfSemiprimes() {
return true;
}
euler278();
linearCombinationOfSemiprimes();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4841000cf542c50ff96
title: 'Problem 279: Triangles with integral sides and an integral angle'
title: 'Problema 279: Triângulos com lados e ângulo em números inteiros'
challengeType: 5
forumTopicId: 301929
dashedName: problem-279-triangles-with-integral-sides-and-an-integral-angle
@ -8,14 +8,14 @@ dashedName: problem-279-triangles-with-integral-sides-and-an-integral-angle
# --description--
How many triangles are there with integral sides, at least one integral angle (measured in degrees), and a perimeter that does not exceed 108?
Quantos triângulos existem com lados compostos de números inteiros, ao menos um ângulo em número inteiro (medido em graus) e com um perímetro que não exceda ${10}^8$?
# --hints--
`euler279()` should return 416577688.
`trianglesWithIntegralSidesAndAngle()` deve retornar `416577688`.
```js
assert.strictEqual(euler279(), 416577688);
assert.strictEqual(trianglesWithIntegralSidesAndAngle(), 416577688);
```
# --seed--
@ -23,12 +23,12 @@ assert.strictEqual(euler279(), 416577688);
## --seed-contents--
```js
function euler279() {
function trianglesWithIntegralSidesAndAngle() {
return true;
}
euler279();
trianglesWithIntegralSidesAndAngle();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4841000cf542c50ff97
title: 'Problem 280: Ant and seeds'
title: 'Problema 280: Formiga e sementes'
challengeType: 5
forumTopicId: 301931
dashedName: problem-280-ant-and-seeds
@ -8,18 +8,18 @@ dashedName: problem-280-ant-and-seeds
# --description--
A laborious ant walks randomly on a 5x5 grid. The walk starts from the central square. At each step, the ant moves to an adjacent square at random, without leaving the grid; thus there are 2, 3 or 4 possible moves at each step depending on the ant's position.
Uma formiga trabalhadora anda aleatoriamente em uma grade de 5x5. A caminhada começa do quadrado central. Em cada etapa, a formiga se move aleatoriamente para um quadrado adjacente, sem sair da grade; assim, há 2, 3 ou 4 movimentos possíveis para cada passo, dependendo da posição da formiga.
At the start of the walk, a seed is placed on each square of the lower row. When the ant isn't carrying a seed and reaches a square of the lower row containing a seed, it will start to carry the seed. The ant will drop the seed on the first empty square of the upper row it eventually reaches.
No início da caminhada, uma semente é colocada em cada quadrado da linha inferior. Quando a formiga não estiver carregando uma semente e atingir um quadrado da linha inferior que contém uma semente, começará a carregar a semente. A formiga soltará a semente no primeiro quadrado vazio da linha superior que ela eventualmente alcance.
What's the expected number of steps until all seeds have been dropped in the top row? Give your answer rounded to 6 decimal places.
Qual é o número esperado de passos até que todas as sementes sejam largadas na linha superior? Dê sua resposta arredondada para 6 casas decimais.
# --hints--
`euler280()` should return 430.088247.
`antAndSeeds()` deve retornar `430.088247`.
```js
assert.strictEqual(euler280(), 430.088247);
assert.strictEqual(antAndSeeds(), 430.088247);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler280(), 430.088247);
## --seed-contents--
```js
function euler280() {
function antAndSeeds() {
return true;
}
euler280();
antAndSeeds();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4861000cf542c50ff98
title: 'Problem 281: Pizza Toppings'
title: 'Problema 281: Coberturas de pizza'
challengeType: 5
forumTopicId: 301932
dashedName: problem-281-pizza-toppings
@ -8,20 +8,22 @@ dashedName: problem-281-pizza-toppings
# --description--
You are given a pizza (perfect circle) that has been cut into m·n equal pieces and you want to have exactly one topping on each slice.
Você recebe uma pizza (círculo perfeito) que foi cortada em $m·n$ peças iguais e você quer ter exatamente um sabor em cada fatia.
Let f(m,n) denote the number of ways you can have toppings on the pizza with m different toppings (m ≥ 2), using each topping on exactly n slices (n ≥ 1). Reflections are considered distinct, rotations are not.
Considere $f(m,n)$ como o número de maneiras de ter coberturas de pizza com $m$ sabores diferentes ($m ≥ 2$), usando cada cobertura em exatamente $n$ fatias ($n ≥ 1$). Reflexões são consideradas distintas, mas as rotações não são.
Thus, for instance, f(2,1) = 1, f(2,2) = f(3,1) = 2 and f(3,2) = 16. f(3,2) is shown below:
Assim, por exemplo, $f(2,1) = 1$, $f(2,2) = f(3,1) = 2$ e $f(3,2) = 16$. $f(3,2)$ é mostrado abaixo:
Find the sum of all f(m,n) such that f(m,n) ≤ 1015.
<img class="img-responsive center-block" alt="animação com 16 maneiras de ter 3 coberturas diferentes em 2 fatias cada" src="https://cdn.freecodecamp.org/curriculum/project-euler/pizza-toppings.gif" style="background-color: white; padding: 10px;" />
Encontre a soma de todos os $f(m,n)$, tal que $f(m,n) £ {10}^{15}$.
# --hints--
`euler281()` should return 1485776387445623.
`pizzaToppings()` deve retornar `1485776387445623`.
```js
assert.strictEqual(euler281(), 1485776387445623);
assert.strictEqual(pizzaToppings(), 1485776387445623);
```
# --seed--
@ -29,12 +31,12 @@ assert.strictEqual(euler281(), 1485776387445623);
## --seed-contents--
```js
function euler281() {
function pizzaToppings() {
return true;
}
euler281();
pizzaToppings();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4861000cf542c50ff99
title: 'Problem 282: The Ackermann function'
title: 'Problema 282: A função de Ackermann'
challengeType: 5
forumTopicId: 301933
dashedName: problem-282-the-ackermann-function
@ -8,18 +8,20 @@ dashedName: problem-282-the-ackermann-function
# --description--
For non-negative integers m, n, the Ackermann function A(m, n) is defined as follows:
Para números inteiros não negativos $m$, $n$, a função de Ackermann $A(m, n)$ é definida da seguinte forma:
For example A(1, 0) = 2, A(2, 2) = 7 and A(3, 4) = 125.
$$A(m, n) = \begin{cases} n + 1 & \text{if $m = 0$} \\\\ A(m - 1, 1) & \text{if $m > 0$ and $n = 0$} \\\\ A(m - 1, A(m, n - 1)) & \text{if $m > 0$ and $n > 0$} \end{cases}$$
Find A(n, n) and give your answer mod 148.
Por exemplo $A(1, 0) = 2$, $A(2, 2) = 7$ e $A(3, 4) = 125$.
Encontre $\displaystyle\sum_{n = 0}^6 A(n, n)$ e dê sua resposta mod ${14}^8$.
# --hints--
`euler282()` should return 1098988351.
`ackermanFunction()` deve retornar `1098988351`.
```js
assert.strictEqual(euler282(), 1098988351);
assert.strictEqual(ackermanFunction(), 1098988351);
```
# --seed--
@ -27,12 +29,12 @@ assert.strictEqual(euler282(), 1098988351);
## --seed-contents--
```js
function euler282() {
function ackermanFunction() {
return true;
}
euler282();
ackermanFunction();
```
# --solutions--

View File

@ -1,7 +1,7 @@
---
id: 5900f4881000cf542c50ff9a
title: >-
Problem 283: Integer sided triangles for which the area * perimeter ratio is integral
Problema 283: Triângulos com lados de números inteiros para os quais a proporção de área * perímetro é um número inteiro
challengeType: 5
forumTopicId: 301934
dashedName: >-
@ -10,22 +10,22 @@ dashedName: >-
# --description--
Consider the triangle with sides 6, 8 and 10. It can be seen that the perimeter and the area are both equal to 24.
Considere o triângulo com os lados 6, 8 e 10. Podemos ver que o perímetro e a área são ambos equivalentes a 24.
So the area/perimeter ratio is equal to 1.
Portanto, a proporção $\frac{\text{área}}{\text{perímetro}}$ é igual a 1.
Consider also the triangle with sides 13, 14 and 15. The perimeter equals 42 while the area is equal to 84.
Considere o triângulo com os lados 13, 14 e 15. O perímetro é igual a 42, enquanto a área é igual a 84.
So for this triangle the area/perimeter ratio is equal to 2.
Assim, para esse triângulo, a proporção $\frac{\text{área}}{\text{perímetro}}$ é igual a 2.
Find the sum of the perimeters of all integer sided triangles for which the area/perimeter ratios are equal to positive integers not exceeding 1000.
Encontre a soma dos perímetros de todos os triângulos com os lados de números inteiros para os quais as proporções da área/perímetro são iguais a números inteiros positivos que não excedem 1000.
# --hints--
`euler283()` should return 28038042525570324.
`integralAreaPerimeterRatio()` deve retornar `28038042525570324`.
```js
assert.strictEqual(euler283(), 28038042525570324);
assert.strictEqual(integralAreaPerimeterRatio(), 28038042525570324);
```
# --seed--
@ -33,12 +33,12 @@ assert.strictEqual(euler283(), 28038042525570324);
## --seed-contents--
```js
function euler283() {
function integralAreaPerimeterRatio() {
return true;
}
euler283();
integralAreaPerimeterRatio();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f4891000cf542c50ff9b
title: 'Problem 284: Steady Squares'
title: 'Problema 284: Quadrados estáveis'
challengeType: 5
forumTopicId: 301935
dashedName: problem-284-steady-squares
@ -8,20 +8,26 @@ dashedName: problem-284-steady-squares
# --description--
The 3-digit number 376 in the decimal numbering system is an example of numbers with the special property that its square ends with the same digits: 3762 = 141376. Let's call a number with this property a steady square.
O número de 3 algarismos 376 no sistema de numeração decimal é um exemplo de números com a propriedade especial de que o quadrado termina com os mesmos algarismos: ${376}^2 = 141376$. Vamos chamar um número com essa propriedade de um quadrado estável.
Steady squares can also be observed in other numbering systems. In the base 14 numbering system, the 3-digit number c37 is also a steady square: c372 = aa0c37, and the sum of its digits is c+3+7=18 in the same numbering system. The letters a, b, c and d are used for the 10, 11, 12 and 13 digits respectively, in a manner similar to the hexadecimal numbering system.
Os quadrados estáveis também podem ser observados em outros sistemas de numeração. No sistema de numeração de base 14, o número de 3 algarismos $c37$ também é um quadrado estável: $c37^2 = aa0c37$ e a soma de seus algarismos é $c+3+7=18$ no mesmo sistema de numeração. As letras $a$, $b$, $c$ e $d$ são usadas para os algarismos 10, 11, 12 e 13, respectivamente, de uma maneira semelhante ao sistema de numeração hexadecimal.
For 1 ≤ n ≤ 9, the sum of the digits of all the n-digit steady squares in the base 14 numbering system is 2d8 (582 decimal). Steady squares with leading 0's are not allowed.
Para $1 ≤ n ≤ 9$, a soma dos algarismos de todos os quadrados estáveis de $n$ algarismos no sistema de numeração de base 14 é $2d8$ (582 no sistema decimal). Não são permitidos quadrados estáveis com zeros à esquerda.
Find the sum of the digits of all the n-digit steady squares in the base 14 numbering system for 1 ≤ n ≤ 10000 (decimal) and give your answer in the base 14 system using lower case letters where necessary.
Encontre a soma dos algarismos de todos os quadrados estáveis de $n$ algarismos no sistema de numeração de base 14 para $1 ≤ n ≤ 10000$ (no sistema decimal) e dê sua resposta como uma string no sistema de base 14 usando letras minúsculas, quando necessário.
# --hints--
`euler284()` should return 5a411d7b.
`steadySquares()` deve retornar uma string.
```js
assert.strictEqual(euler284(), '5a411d7b');
assert(typeof steadySquares() === 'string');
```
`steadySquares()` deve retornar a string `5a411d7b`.
```js
assert.strictEqual(steadySquares(), '5a411d7b');
```
# --seed--
@ -29,12 +35,12 @@ assert.strictEqual(euler284(), '5a411d7b');
## --seed-contents--
```js
function euler284() {
function steadySquares() {
return true;
}
euler284();
steadySquares();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48a1000cf542c50ff9c
title: 'Problem 285: Pythagorean odds'
title: 'Problema 285: Probabilidades pitagóricas'
challengeType: 5
forumTopicId: 301936
dashedName: problem-285-pythagorean-odds
@ -8,22 +8,22 @@ dashedName: problem-285-pythagorean-odds
# --description--
Albert chooses a positive integer k, then two real numbers a, b are randomly chosen in the interval \[0,1] with uniform distribution.
Albert escolhe um número inteiro positivo $k$, depois dois números reais $a$, $b$ são escolhidos aleatoriamente no intervalo [0,1] com distribuição uniforme.
The square root of the sum (k·a+1)2 + (k·b+1)2 is then computed and rounded to the nearest integer. If the result is equal to k, he scores k points; otherwise he scores nothing.
A raiz quadrada da soma ${(ka + 1)}^2 + {(kb + 1)}^2$ é então computada e arredondada para o número inteiro mais próximo. Se o resultado for igual a $k$, ele pontua $k$ pontos. Caso contrário, ele não pontua.
For example, if k = 6, a = 0.2 and b = 0.85, then (k·a+1)2 + (k·b+1)2 = 42.05. The square root of 42.05 is 6.484... and when rounded to the nearest integer, it becomes 6. This is equal to k, so he scores 6 points.
Por exemplo, if $k = 6$, $a = 0.2$ e $b = 0.85$, então ${(ka + 1)}^2 + {(kb + 1)}^2 = 42.05$. A raiz quadrada de 42,05 é 6,484... e, quando arredondada para o inteiro mais próximo, ela se torna 6. Isso é igual a $k$, então ele marca 6 pontos.
It can be shown that if he plays 10 turns with k = 1, k = 2, ..., k = 10, the expected value of his total score, rounded to five decimal places, is 10.20914.
Pode-se mostra que, se ele jogar 10 vezes, com $k = 1, k = 2, \ldots, k = 10$, o valor esperado de sua pontuação total, arredondado para cinco casas decimais, é 10,20914.
If he plays 105 turns with k = 1, k = 2, k = 3, ..., k = 105, what is the expected value of his total score, rounded to five decimal places?
Se ele jogar ${10}^5$ vezes com $k = 1, k = 2, k = 3, \ldots, k = {10}^5$, qual é o valor esperado de sua pontuação total, arredondada para cinco casas decimais?
# --hints--
`euler285()` should return 157055.80999.
`pythagoreanOdds()` deve retornar `157055.80999`.
```js
assert.strictEqual(euler285(), 157055.80999);
assert.strictEqual(pythagoreanOdds(), 157055.80999);
```
# --seed--
@ -31,12 +31,12 @@ assert.strictEqual(euler285(), 157055.80999);
## --seed-contents--
```js
function euler285() {
function pythagoreanOdds() {
return true;
}
euler285();
pythagoreanOdds();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48a1000cf542c50ff9d
title: 'Problem 286: Scoring probabilities'
title: 'Problema 286: Probabilidades de pontuação'
challengeType: 5
forumTopicId: 301937
dashedName: problem-286-scoring-probabilities
@ -8,18 +8,18 @@ dashedName: problem-286-scoring-probabilities
# --description--
Barbara is a mathematician and a basketball player. She has found that the probability of scoring a point when shooting from a distance x is exactly (1 - x/q), where q is a real constant greater than 50.
Barbara é matemática e jogadora de basquete. Ela descobriu que a probabilidade de marcar um ponto ao lançar a bola de uma distância $x$ é exatamente ($1 - \frac{x}{q}$), onde $q$ é uma constante real maior que 50.
During each practice run, she takes shots from distances x = 1, x = 2, ..., x = 50 and, according to her records, she has precisely a 2 % chance to score a total of exactly 20 points.
Durante cada prática, ela arremessa das distâncias $x = 1, x = 2, \ldots, x = 50$ e, de acordo com os seus registros, tem precisamente 2% de chance de fazer um total de 20 pontos.
Find q and give your answer rounded to 10 decimal places.
Encontre $q$ e dê sua resposta arredondada para 10 casas decimais.
# --hints--
`euler286()` should return 52.6494571953.
`scoringProbabilities()` deve retornar `52.6494571953`.
```js
assert.strictEqual(euler286(), 52.6494571953);
assert.strictEqual(scoringProbabilities(), 52.6494571953);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler286(), 52.6494571953);
## --seed-contents--
```js
function euler286() {
function scoringProbabilities() {
return true;
}
euler286();
scoringProbabilities();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48b1000cf542c50ff9e
title: 'Problem 287: Quadtree encoding (a simple compression algorithm)'
title: 'Problema 287: Codificação quadtree (um algoritmo simples de compressão)'
challengeType: 5
forumTopicId: 301938
dashedName: problem-287-quadtree-encoding-a-simple-compression-algorithm
@ -8,30 +8,35 @@ dashedName: problem-287-quadtree-encoding-a-simple-compression-algorithm
# --description--
The quadtree encoding allows us to describe a 2N×2N black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this:
A codificação quadtree nos permite descrever uma imagem $2^N×2^N$ preta e branca como uma sequência de bits (0 e 1). Essas sequências devem ser lidas da esquerda para a direita assim:
the first bit deals with the complete 2N×2N region;
- o primeiro bit tem a ver com a região completa do $2^N×2^N$;
- "0" indica uma divisão:
- a região atual $2^n×2^n$ é dividida em 4 sub-regiões de dimensão $2^{n - 1}×2^{n - 1}$,
- os próximos bits contêm a descrição das sub-regiões superior esquerda, superior direita, inferior esquerda e inferior direita - nessa ordem;
- "10" indica que a região atual contém apenas pixels pretos;
- "11" indica que a região atual contém apenas pixels brancos.
"0" denotes a split:
Considere a seguinte imagem 4×4 (pontos coloridos denotam lugares onde uma divisão pode ocorrer):
the current 2n×2n region is divided into 4 sub-regions of dimension 2n-1×2n-1,
<img class="img-responsive center-block" alt="imagem 4x4 com marcas coloridas denotam lugares onde a divisão pode ocorrer" src="https://cdn.freecodecamp.org/curriculum/project-euler/quadtree-encoding-a-simple-compression-algorithm.gif" style="background-color: white; padding: 10px;" />
the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;
Essa imagem pode ser descrita por várias sequências, por exemplo: "<strong><span style="color: red">0</span></strong><strong><span style="color: blue">0</span></strong>10101010<strong><span style="color: green">0</span></strong>1011111011<strong><span style="color: orange">0</span></strong>10101010", de comprimento 30, ou "<strong><span style="color: red">0</span></strong>10<strong><span style="color: green">0</span></strong>101111101110", de comprimento 16, que é a sequência mínima para essa imagem.
"10" indicates that the current region contains only black pixels;
Para um número inteiro positivo $N$, defina $D_N$ como a imagem $2^N×2^N$ com o seguinte esquema de cores:
"11" indicates that the current region contains only white pixels.Consider the following 4×4 image (colored marks denote places where a split can occur):
- o pixel com coordenadas $x = 0$, $y = 0$ corresponde ao pixel inferior esquerdo,
- se ${(x - 2^{N - 1})}^2 + {(y - 2^{N - 1})}^2 ≤ 2^{2N - 2}$, o pixel é preto,
- caso contrário, o pixel é branco.
This image can be described by several sequences, for example : "001010101001011111011010101010", of length 30, or "0100101111101110", of length 16, which is the minimal sequence for this image.
For a positive integer N, define DN as the 2N×2N image with the following coloring scheme: the pixel with coordinates x = 0, y = 0 corresponds to the bottom left pixel, if (x - 2N-1)2 + (y - 2N-1)2 ≤ 22N-2 then the pixel is black, otherwise the pixel is white.What is the length of the minimal sequence describing D24 ?
Qual é o comprimento da sequência mínima que descreve $D_{24}$?
# --hints--
`euler287()` should return 313135496.
`quadtreeEncoding()` deve retornar `313135496`.
```js
assert.strictEqual(euler287(), 313135496);
assert.strictEqual(quadtreeEncoding(), 313135496);
```
# --seed--
@ -39,12 +44,12 @@ assert.strictEqual(euler287(), 313135496);
## --seed-contents--
```js
function euler287() {
function quadtreeEncoding() {
return true;
}
euler287();
quadtreeEncoding();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48d1000cf542c50ff9f
title: 'Problem 288: An enormous factorial'
title: 'Problema 288: Um fatorial enorme'
challengeType: 5
forumTopicId: 301939
dashedName: problem-288-an-enormous-factorial
@ -8,24 +8,24 @@ dashedName: problem-288-an-enormous-factorial
# --description--
For any prime p the number N(p,q) is defined by
Para qualquer número primo $p$, o número $N(p,q)$ é definido por $N(p,q) = \sum_{n=0}^q T_n \times p^n$ com $T_n$ gerado pelo seguinte gerador aleatório de números:
N(p,q) = ∑n=0 to q Tn\*pn with Tn generated by the following random number generator:
$$\begin{align} & S_0 = 290797 \\\\ & S_{n + 1} = {S_n}^2\bmod 50.515.093 \\\\ & T_n = S_n\bmod p \end{align}$$
S0 = 290797 Sn+1 = Sn2 mod 50515093 Tn = Sn mod p
Considere $Nfac(p,q)$ como o fatorial de $N(p,q)$.
Let Nfac(p,q) be the factorial of N(p,q). Let NF(p,q) be the number of factors p in Nfac(p,q).
Considere $NF(p,q)$ como o número de divisores $p$ em $Nfac(p,q)$.
You are given that NF(3,10000) mod 320=624955285.
Você é informado de que $NF(3,10000) \bmod 3^{20} = 624.955.285$.
Find NF(61,107) mod 6110
Encontre $NF(61,{10}^7)\bmod {61}^{10}$.
# --hints--
`euler288()` should return 605857431263982000.
`enormousFactorial()` deve retornar `605857431263982000`.
```js
assert.strictEqual(euler288(), 605857431263982000);
assert.strictEqual(enormousFactorial(), 605857431263982000);
```
# --seed--
@ -33,12 +33,12 @@ assert.strictEqual(euler288(), 605857431263982000);
## --seed-contents--
```js
function euler288() {
function enormousFactorial() {
return true;
}
euler288();
enormousFactorial();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48d1000cf542c50ffa0
title: 'Problem 289: Eulerian Cycles'
title: 'Problema 289: Ciclos eulerianos'
challengeType: 5
forumTopicId: 301940
dashedName: problem-289-eulerian-cycles
@ -8,24 +8,26 @@ dashedName: problem-289-eulerian-cycles
# --description--
Let C(x,y) be a circle passing through the points (x, y), (x, y+1), (x+1, y) and (x+1, y+1).
Considere $C(x,y)$ como um círculo passando pelos pontos ($x$, $y$), ($x$, $y + 1$), ($x + 1$, $y$) e ($x + 1$, $y + 1$).
For positive integers m and n, let E(m,n) be a configuration which consists of the m·n circles: { C(x,y): 0 ≤ x &lt; m, 0 ≤ y &lt; n, x and y are integers }
Para os números positivos inteiros $m$ e $n$, considere $E(m,n)$ como a configuração que consiste em $m·n$ círculos: { $C(x,y)$: $0 ≤ x &lt; m$, $0 ≤ y &lt; n$, sendo que $x$ e $y$ são números inteiros }
An Eulerian cycle on E(m,n) is a closed path that passes through each arc exactly once. Many such paths are possible on E(m,n), but we are only interested in those which are not self-crossing: A non-crossing path just touches itself at lattice points, but it never crosses itself.
Um ciclo euleriano em $E(m,n)$ é um caminho fechado que passa por cada arco exatamente uma vez. Muitos caminhos são possíveis em $E(m,n)$, mas apenas nos interessamos por aqueles que não são cruzam a si mesmos: um caminho que não cruze a si mesmo apenas toca nos pontos da rede, mas nunca cruza a si mesmo.
The image below shows E(3,3) and an example of an Eulerian non-crossing path.
A imagem abaixo mostra $E(3,3)$ e um exemplo de um caminho que euleriano sem cruzamentos.
Let L(m,n) be the number of Eulerian non-crossing paths on E(m,n). For example, L(1,2) = 2, L(2,2) = 37 and L(3,3) = 104290.
<img class="img-responsive center-block" alt="ciclo Euleriano (3, 3) e caminho euleriano sem cruzamento" src="https://cdn.freecodecamp.org/curriculum/project-euler/eulerian-cycles.gif" style="background-color: white; padding: 10px;" />
Find L(6,10) mod 1010.
Considere $L(m,n)$ como o número de caminhos eulerianos sem cruzamento em $E(m,n)$. Por exemplo, $L(1,2) = 2$, $L(2,2) = 37$ e $L(3,3) = 104290$.
Encontre $L(6,10)\bmod {10}^{10}$.
# --hints--
`euler289()` should return 6567944538.
`eulerianCycles()` deve retornar `6567944538`.
```js
assert.strictEqual(euler289(), 6567944538);
assert.strictEqual(eulerianCycles(), 6567944538);
```
# --seed--
@ -33,12 +35,12 @@ assert.strictEqual(euler289(), 6567944538);
## --seed-contents--
```js
function euler289() {
function eulerianCycles() {
return true;
}
euler289();
eulerianCycles();
```
# --solutions--

View File

@ -1,6 +1,6 @@
---
id: 5900f48f1000cf542c50ffa1
title: 'Problem 290: Digital Signature'
title: 'Problema 290: Assinatura digital'
challengeType: 5
forumTopicId: 301942
dashedName: problem-290-digital-signature
@ -8,14 +8,14 @@ dashedName: problem-290-digital-signature
# --description--
How many integers 0 ≤ n &lt; 1018 have the property that the sum of the digits of n equals the sum of digits of 137n?
Quantos números inteiro $0 ≤ n &lt; {10}^{18}$ têm a propriedade de que a soma dos algarismos de $n$ é igual à soma dos algarismos de $137n$?
# --hints--
`euler290()` should return 20444710234716470.
`digitalSignature()` deve retornar `20444710234716470`.
```js
assert.strictEqual(euler290(), 20444710234716470);
assert.strictEqual(digitalSignature(), 20444710234716470);
```
# --seed--
@ -23,12 +23,12 @@ assert.strictEqual(euler290(), 20444710234716470);
## --seed-contents--
```js
function euler290() {
function digitalSignature() {
return true;
}
euler290();
digitalSignature();
```
# --solutions--