chore(i18n,curriculum): update translations (#43178)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3d21000cf542c50fee5
|
||||
title: 'Problem 102: Triangle containment'
|
||||
title: 'Problema 102: Contenção Triangular'
|
||||
challengeType: 5
|
||||
forumTopicId: 301726
|
||||
dashedName: problem-102-triangle-containment
|
||||
@ -8,9 +8,9 @@ dashedName: problem-102-triangle-containment
|
||||
|
||||
# --description--
|
||||
|
||||
Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.
|
||||
Três pontos distintos são colocados aleatoriamente em um plano cartesiano, para o qual -1000 ≤ x, y ≤ 1000, de modo que um triângulo seja formado.
|
||||
|
||||
Consider the following two triangles:
|
||||
Considere o seguinte exemplo com dois triângulos:
|
||||
|
||||
```js
|
||||
const exampleTriangles = [
|
||||
@ -19,31 +19,31 @@ const exampleTriangles = [
|
||||
];
|
||||
```
|
||||
|
||||
It can be verified that first triangle contains the origin, whereas second triangle does not.
|
||||
É possível verificar que o primeiro triângulo contém a origem, ao passo que o segundo triângulo não.
|
||||
|
||||
Using the `triangles` array containing coordinates of triangles, find the number of triangles for which the interior contains the origin.
|
||||
Usando o array `triangles` contendo coordenadas de triângulos, descubra o número de triângulos para os quais o interior contém a origem.
|
||||
|
||||
# --hints--
|
||||
|
||||
`triangleContainment(exampleTriangles)` should return a number.
|
||||
`triangleContainment(exampleTriangles)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof triangleContainment(_exampleTriangles) === 'number');
|
||||
```
|
||||
|
||||
`triangleContainment(exampleTriangles)` should return `1`.
|
||||
`triangleContainment(exampleTriangles)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(triangleContainment(_exampleTriangles), 1);
|
||||
```
|
||||
|
||||
`triangleContainment(testTriangles1)` should return `19`.
|
||||
`triangleContainment(testTriangles1)` deve retornar `19`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(triangleContainment(_testTriangles1), 19);
|
||||
```
|
||||
|
||||
`triangleContainment(testTriangles2)` should return `228`.
|
||||
`triangleContainment(testTriangles2)` deve retornar `228`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(triangleContainment(_testTriangles2), 228);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3d61000cf542c50fee7
|
||||
title: 'Problem 103: Special subset sums: optimum'
|
||||
title: 'Problema 103: Quantidade especial de subconjuntos: ideal'
|
||||
challengeType: 5
|
||||
forumTopicId: 301727
|
||||
dashedName: problem-103-special-subset-sums-optimum
|
||||
@ -8,26 +8,26 @@ dashedName: problem-103-special-subset-sums-optimum
|
||||
|
||||
# --description--
|
||||
|
||||
Let $S(A)$ represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true:
|
||||
Vamos $S(A)$ representar a soma dos elementos no conjunto A, de tamanho n. Vamos chamá-la de uma soma especial definida se, para dois subconjuntos disjuntos, B e C, as seguintes propriedades são verdadeiras:
|
||||
|
||||
1. $S(B) ≠ S(C)$; that is, sums of subsets cannot be equal.
|
||||
2. If B contains more elements than C then $S(B) > S(C)$.
|
||||
1. $S(B) ≠ S(C)$; ou seja, somas de subconjuntos não podem ser iguais.
|
||||
2. Se B contém mais elementos que C, $S(B) > S(C)$.
|
||||
|
||||
If $S(A)$ is minimised for a given n, we shall call it an optimum special sum set. The first five optimum special sum sets are given below.
|
||||
Se $S(A)$ for minimizado por um determinado n, vamos chamar de um conjunto de soma especial ideal. Os primeiros cinco conjuntos de somas especiais ideais são fornecidos abaixo.
|
||||
|
||||
$$\begin{align} & n = 1: \\{1\\} \\\\ & n = 2: \\{1, 2\\} \\\\ & n = 3: \\{2, 3, 4\\} \\\\ & n = 4: \\{3, 5, 6, 7\\} \\\\ & n = 5: \\{6, 9, 11, 12, 13\\} \\\\ \end{align}$$
|
||||
|
||||
It seems that for a given optimum set, $A = \\{a_1, a_2, \ldots, a_n\\}$, the next optimum set is of the form $B = \\{b, a_1 + b, a_2 + b, \ldots, a_n + b\\}$, where b is the "middle" element on the previous row.
|
||||
Parece que, para um determinado conjunto ideal, $A = \\{a_1, a_2, \ldots, a_n\\}$, o próximo conjunto ideal é do formato $B = \\{b, a_1 + b, a_2 + b, \ldots, a_n + b\\}$, onde b é o elemento do "meio" na linha anterior.
|
||||
|
||||
By applying this "rule" we would expect the optimum set for $n = 6$ to be $A = \\{11, 17, 20, 22, 23, 24\\}$, with $S(A) = 117$. However, this is not the optimum set, as we have merely applied an algorithm to provide a near optimum set. The optimum set for $n = 6$ is $A = \\{11, 18, 19, 20, 22, 25\\}$, with $S(A) = 115$ and corresponding set string: `111819202225`.
|
||||
Aplicando esta "regra", esperaríamos que o conjunto ideal para $n = 6$ fosse $A = \\{11, 17, 20, 22, 23, 24\\}$, com $S(A) = 117$. No entanto, este não é o conjunto ideal, já que apenas aplicamos um algoritmo para fornecer um conjunto quase ideal. O conjunto ideal para $n = 6$ é $A = \\{11, 18, 19, 20, 22, 25\\}$, com $S(A) = 115$ e string correspondente do conjunto: `111819202225`.
|
||||
|
||||
Given that A is an optimum special sum set for $n = 7$, find its set string.
|
||||
Dado que A é uma soma especial ideal para $n = 7$, encontre sua string definida.
|
||||
|
||||
**Note:** This problem is related to Problem 105 and Problem 106.
|
||||
**Observação:** este problema está relacionado ao Problema 105 e ao Problema 106.
|
||||
|
||||
# --hints--
|
||||
|
||||
`optimumSpecialSumSet()` should return the string `20313839404245`.
|
||||
`optimumSpecialSumSet()` deve retornar a string `20313839404245`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(optimumSpecialSumSet(), '20313839404245');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3861000cf542c50fe99
|
||||
title: 'Problem 26: Reciprocal cycles'
|
||||
title: 'Problema 26: Dízimas periódicas'
|
||||
challengeType: 5
|
||||
forumTopicId: 301908
|
||||
dashedName: problem-26-reciprocal-cycles
|
||||
@ -8,41 +8,41 @@ dashedName: problem-26-reciprocal-cycles
|
||||
|
||||
# --description--
|
||||
|
||||
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:
|
||||
Em uma fração unitária, o numerador é 1. A representação decimal das frações unitárias com denominadores de 2 a 10 é a seguinte:
|
||||
|
||||
<div style='padding-left: 4em; display: inline-grid; grid-template-rows: auto; row-gap: 7px;'><div><sup>1</sup>/<sub>2</sub> = 0.5</div><div><sup>1</sup>/<sub>3</sub> = 0.(3)</div><div><sup>1</sup>/<sub>4</sub> = 0.25</div><div><sup>1</sup>/<sub>5</sub> = 0.2</div><div><sup>1</sup>/<sub>6</sub> = 0.1(6)</div><div><sup>1</sup>/<sub>7</sub> = 0.(142857)</div><div><sup>1</sup>/<sub>8</sub> = 0.125</div><div><sup>1</sup>/<sub>9</sub> = 0.(1)</div><div><sup>1</sup>/<sub>10</sub> = 0.1</div></div>
|
||||
|
||||
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that <sup>1</sup>/<sub>7</sub> has a 6-digit recurring cycle.
|
||||
A expressão 0.1(6) significa 0.16666666... e tem um ciclo recorrente (que se repete) de 1 algarismo. Podemos notar que <sup>1</sup>/<sub>7</sub> tem um ciclo recorrente de 6 dígitos.
|
||||
|
||||
Find the value of `d` < `n` for which <sup>1</sup>/<sub>d</sub> contains the longest recurring cycle in its decimal fraction part.
|
||||
Calcule o valor de `d` < `n` onde <sup>1</sup>/<sub>d</sub> contém o ciclo recorrente mais longo na parte decimal.
|
||||
|
||||
# --hints--
|
||||
|
||||
`reciprocalCycles(700)` should return a number.
|
||||
`reciprocalCycles(700)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof reciprocalCycles(700) === 'number');
|
||||
```
|
||||
|
||||
`reciprocalCycles(700)` should return 659.
|
||||
`reciprocalCycles(700)` deve retornar 659.
|
||||
|
||||
```js
|
||||
assert(reciprocalCycles(700) == 659);
|
||||
```
|
||||
|
||||
`reciprocalCycles(800)` should return 743.
|
||||
`reciprocalCycles(800)` deve retornar 743.
|
||||
|
||||
```js
|
||||
assert(reciprocalCycles(800) == 743);
|
||||
```
|
||||
|
||||
`reciprocalCycles(900)` should return 887.
|
||||
`reciprocalCycles(900)` deve retornar 887.
|
||||
|
||||
```js
|
||||
assert(reciprocalCycles(900) == 887);
|
||||
```
|
||||
|
||||
`reciprocalCycles(1000)` should return 983.
|
||||
`reciprocalCycles(1000)` deve retornar 983.
|
||||
|
||||
```js
|
||||
assert(reciprocalCycles(1000) == 983);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3871000cf542c50fe9a
|
||||
title: 'Problem 27: Quadratic primes'
|
||||
title: 'Problema 27: Primos quadráticos'
|
||||
challengeType: 5
|
||||
forumTopicId: 301919
|
||||
dashedName: problem-27-quadratic-primes
|
||||
@ -8,51 +8,51 @@ dashedName: problem-27-quadratic-primes
|
||||
|
||||
# --description--
|
||||
|
||||
Euler discovered the remarkable quadratic formula:
|
||||
Euler descobriu a notável fórmula do segundo grau:
|
||||
|
||||
<div style='margin-left: 4em;'>$n^2 + n + 41$</div>
|
||||
|
||||
It turns out that the formula will produce 40 primes for the consecutive integer values $0 \\le n \\le 39$. However, when $n = 40, 40^2 + 40 + 41 = 40(40 + 1) + 41$ is divisible by 41, and certainly when $n = 41, 41^2 + 41 + 41$ is clearly divisible by 41.
|
||||
Essa fórmula vai produzir 40 números primos para os valores inteiros consecutivos $0 \\le n \\le 39$. No entanto, quando temos $n = 40, 40^2 + 40 + 41 = 40(40 + 1) + 41$ é divisível por 41, e certamente quando temos $n = 41, 41^2 + 41 + 41$ é claramente divisível por 41.
|
||||
|
||||
The incredible formula $n^2 - 79n + 1601$ was discovered, which produces 80 primes for the consecutive values $0 \\le n \\le 79$. The product of the coefficients, −79 and 1601, is −126479.
|
||||
Uma fórmula incrível foi descoberta, $n^2 - 79n + 1601$, que produz 80 primos para os valores de $0 \\le n \\le 79$ consecutivos. O produto dos coeficientes, −79 e 1601, é -126479.
|
||||
|
||||
Considering quadratics of the form:
|
||||
Considerando os quadráticos da fórmula:
|
||||
|
||||
<div style='margin-left: 4em;'>
|
||||
$n^2 + an + b$, where $|a| < range$ and $|b| \le range$<br>
|
||||
where $|n|$ is the modulus/absolute value of $n$<br>
|
||||
e.g. $|11| = 11$ and $|-4| = 4$<br>
|
||||
$n^2 + an + b$, onde $➲ a├< range$ e $├b├\le range$<br>
|
||||
onde $├n├$ é o valor modulo/absoluto de $n$<br>
|
||||
exemplo: $➲ 11├= 11$ e $├-4^\\= 4$<br>
|
||||
</div>
|
||||
|
||||
Find the product of the coefficients, $a$ and $b$, for the quadratic expression that produces the maximum number of primes for consecutive values of $n$, starting with $n = 0$.
|
||||
Encontre o produto dos coeficientes, $a$ e $b$, para a expressão do segundo grau que produz o número máximo de primos para valores consecutivos de $n$, começando com $n = 0$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`quadraticPrimes(200)` should return a number.
|
||||
`quadraticPrimes(200)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof quadraticPrimes(200) === 'number');
|
||||
```
|
||||
|
||||
`quadraticPrimes(200)` should return -4925.
|
||||
`quadraticPrimes(200)` deve retornar -4925.
|
||||
|
||||
```js
|
||||
assert(quadraticPrimes(200) == -4925);
|
||||
```
|
||||
|
||||
`quadraticPrimes(500)` should return -18901.
|
||||
`quadraticPrimes(500)` deve retornar -18901.
|
||||
|
||||
```js
|
||||
assert(quadraticPrimes(500) == -18901);
|
||||
```
|
||||
|
||||
`quadraticPrimes(800)` should return -43835.
|
||||
`quadraticPrimes(800)` deve retornar -43835.
|
||||
|
||||
```js
|
||||
assert(quadraticPrimes(800) == -43835);
|
||||
```
|
||||
|
||||
`quadraticPrimes(1000)` should return -59231.
|
||||
`quadraticPrimes(1000)` deve retornar -59231.
|
||||
|
||||
```js
|
||||
assert(quadraticPrimes(1000) == -59231);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f38d1000cf542c50fea0
|
||||
title: 'Problem 33: Digit cancelling fractions'
|
||||
title: 'Problema 33: Frações com cancelamento de dígitos'
|
||||
challengeType: 5
|
||||
forumTopicId: 301987
|
||||
dashedName: problem-33-digit-cancelling-fractions
|
||||
@ -8,23 +8,23 @@ dashedName: problem-33-digit-cancelling-fractions
|
||||
|
||||
# --description--
|
||||
|
||||
The fraction <sup>49</sup>/<sub>98</sub> is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that <sup>49</sup>/<sub>98</sub> = <sup>4</sup>/<sub>8</sub>, which is correct, is obtained by cancelling the 9s.
|
||||
A fração <sup>49</sup>/<sub>98</sub> é uma fração curiosa, já que um matemático inexperiente, na tentativa de simplificá-la, pode acreditar, erroneamente, que <sup>49</sup>/<sub>98</sub> = <sup>4</sup>/<sub>8</sub> pelo cancelamento dos dígitos 9. Embora o resultado esteja correto, o raciocínio não está.
|
||||
|
||||
We shall consider fractions like, <sup>30</sup>/<sub>50</sub> = <sup>3</sup>/<sub>5</sub>, to be trivial examples.
|
||||
Devemos considerar frações como, por exemplo, <sup>30</sup>/<sub>50</sub> = <sup>3</sup>/<sub>5</sub>, como exemplos triviais.
|
||||
|
||||
There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
|
||||
Existem exatamente quatro exemplos não triviais desse tipo de fração, com resultado inferior a 1 e que contêm dois dígitos no numerador e no denominador.
|
||||
|
||||
If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
|
||||
Se o produto dessas quatro frações é dado por seus mínimos divisores comuns, encontre o valor do denominador.
|
||||
|
||||
# --hints--
|
||||
|
||||
`digitCancellingFractions()` should return a number.
|
||||
`digitCancellingFractions()` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof digitCancellingFractions() === 'number');
|
||||
```
|
||||
|
||||
`digitCancellingFractions()` should return 100.
|
||||
`digitCancellingFractions()` deve retornar 100.
|
||||
|
||||
```js
|
||||
assert.strictEqual(digitCancellingFractions(), 100);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f38e1000cf542c50fea1
|
||||
title: 'Problem 34: Digit factorials'
|
||||
title: 'Problema 34: Dígitos dos fatoriais'
|
||||
challengeType: 5
|
||||
forumTopicId: 301998
|
||||
dashedName: problem-34-digit-factorials
|
||||
@ -8,21 +8,21 @@ dashedName: problem-34-digit-factorials
|
||||
|
||||
# --description--
|
||||
|
||||
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
|
||||
145 é um número curioso, pois 1! + 4! + 5! = 1 + 24 + 120 = 145.
|
||||
|
||||
Find the numbers and the sum of the numbers which are equal to the sum of the factorial of their digits.
|
||||
Calcule os números e a soma dos números que são iguais à soma do fatorial de seus dígitos.
|
||||
|
||||
**Note:** as 1! = 1 and 2! = 2 are not sums they are not included.
|
||||
**Observação:** como 1! = 1 e 2! = 2 não são somas, eles não estão incluídos.
|
||||
|
||||
# --hints--
|
||||
|
||||
`digitFactorial()` should return an object.
|
||||
`digitFactorial()` deve retornar um objeto.
|
||||
|
||||
```js
|
||||
assert.typeOf(digitFactorial(), 'object');
|
||||
```
|
||||
|
||||
`digitFactorial()` should return { sum: 40730, numbers: [145, 40585] }.
|
||||
`digitFactorial()` deve retornar { sum: 40730, numbers: [145, 40585] }.
|
||||
|
||||
```js
|
||||
assert.deepEqual(digitFactorial(), { sum: 40730, numbers: [145, 40585] });
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f38f1000cf542c50fea2
|
||||
title: 'Problem 35: Circular primes'
|
||||
title: 'Problema 35: Números primos circulares'
|
||||
challengeType: 5
|
||||
forumTopicId: 302009
|
||||
dashedName: problem-35-circular-primes
|
||||
@ -8,55 +8,55 @@ dashedName: problem-35-circular-primes
|
||||
|
||||
# --description--
|
||||
|
||||
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
|
||||
O número 197 é chamado de primo circular porque todas as rotações dos dígitos: 197, 971 e 719 formam números primos.
|
||||
|
||||
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
|
||||
Há treze números primos menores que 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79 e 97.
|
||||
|
||||
How many circular primes are there below `n`, whereas 100 ≤ `n` ≤ 1000000?
|
||||
Quantos números primos circulares existem abaixo de `n`, onde 100 ≤ `n` ≤ 1000000?
|
||||
|
||||
**Note:**
|
||||
**Observação:**
|
||||
|
||||
Circular primes individual rotation can exceed `n`.
|
||||
A rotação dos números primos circulares pode ser maior que `n`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`circularPrimes(100)` should return a number.
|
||||
`circularPrimes(100)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof circularPrimes(100) === 'number');
|
||||
```
|
||||
|
||||
`circularPrimes(100)` should return 13.
|
||||
`circularPrimes(100)` deve retornar 13.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(100) == 13);
|
||||
```
|
||||
|
||||
`circularPrimes(100000)` should return 43.
|
||||
`circularPrimes(100000)` deve retornar 43.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(100000) == 43);
|
||||
```
|
||||
|
||||
`circularPrimes(250000)` should return 45.
|
||||
`circularPrimes(250000)` deve retornar 45.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(250000) == 45);
|
||||
```
|
||||
|
||||
`circularPrimes(500000)` should return 49.
|
||||
`circularPrimes(500000)` deve retornar 49.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(500000) == 49);
|
||||
```
|
||||
|
||||
`circularPrimes(750000)` should return 49.
|
||||
`circularPrimes(750000)` deve retornar 49.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(750000) == 49);
|
||||
```
|
||||
|
||||
`circularPrimes(1000000)` should return 55.
|
||||
`circularPrimes(1000000)` deve retornar 55.
|
||||
|
||||
```js
|
||||
assert(circularPrimes(1000000) == 55);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3901000cf542c50fea3
|
||||
title: 'Problem 36: Double-base palindromes'
|
||||
title: 'Problema 36: Palíndromos de base dupla'
|
||||
challengeType: 5
|
||||
forumTopicId: 302020
|
||||
dashedName: problem-36-double-base-palindromes
|
||||
@ -8,39 +8,39 @@ dashedName: problem-36-double-base-palindromes
|
||||
|
||||
# --description--
|
||||
|
||||
The decimal number, 585 = 1001001001<sub>2</sub> (binary), is palindromic in both bases.
|
||||
O número decimal, 585 = 1001001<sub>2</sub> (binário), é um palíndromo em ambas as bases.
|
||||
|
||||
Find the sum of all numbers, less than `n`, whereas 1000 ≤ `n` ≤ 1000000, which are palindromic in base 10 and base 2.
|
||||
Calcule a soma de todos os números, menores que `n`, onde 1000 ≤ `n` ≤ 1000000, que são palíndromos na base 10 e base 2.
|
||||
|
||||
(Please note that the palindromic number, in either base, may not include leading zeros.)
|
||||
(Note que um número palindrômico, em qualquer base, pode não começar com números zero.)
|
||||
|
||||
# --hints--
|
||||
|
||||
`doubleBasePalindromes(1000)` should return a number.
|
||||
`doubleBasePalindromes(1000)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof doubleBasePalindromes(1000) === 'number');
|
||||
```
|
||||
|
||||
`doubleBasePalindromes(1000)` should return 1772.
|
||||
`doubleBasePalindromes(1000)` deve retornar 1772.
|
||||
|
||||
```js
|
||||
assert(doubleBasePalindromes(1000) == 1772);
|
||||
```
|
||||
|
||||
`doubleBasePalindromes(50000)` should return 105795.
|
||||
`doubleBasePalindromes(50000)` deve retornar 105795.
|
||||
|
||||
```js
|
||||
assert(doubleBasePalindromes(50000) == 105795);
|
||||
```
|
||||
|
||||
`doubleBasePalindromes(500000)` should return 286602.
|
||||
`doubleBasePalindromes(500000)` deve retornar 286602.
|
||||
|
||||
```js
|
||||
assert(doubleBasePalindromes(500000) == 286602);
|
||||
```
|
||||
|
||||
`doubleBasePalindromes(1000000)` should return 872187.
|
||||
`doubleBasePalindromes(1000000)` deve retornar 872187.
|
||||
|
||||
```js
|
||||
assert(doubleBasePalindromes(1000000) == 872187);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3911000cf542c50fea4
|
||||
title: 'Problem 37: Truncatable primes'
|
||||
title: 'Problema 37: Números primos truncáveis'
|
||||
challengeType: 5
|
||||
forumTopicId: 302031
|
||||
dashedName: problem-37-truncatable-primes
|
||||
@ -8,39 +8,39 @@ dashedName: problem-37-truncatable-primes
|
||||
|
||||
# --description--
|
||||
|
||||
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
|
||||
O número 3797 tem uma propriedade interessante. Além de ser um número primo, se você remover 1 algarismo da esquerda para a direita, o resultado ainda assim é um número primo: 3797, 797, 97 e 7. Também podemos remover da direita para a esquerda: 3797, 379, 37 e 3.
|
||||
|
||||
Find the sum of the only `n` (8 ≤ `n` ≤ 11) primes that are both truncatable from left to right and right to left.
|
||||
Calcule a soma dos números primos `n` (8 ≤ `n` ≤ 11) que podem ser truncados da esquerda para a direita e vice-versa.
|
||||
|
||||
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.
|
||||
Observação: 2, 3, 5 e 7 não são considerados números primos truncáveis.
|
||||
|
||||
# --hints--
|
||||
|
||||
`truncatablePrimes(8)` should return a number.
|
||||
`truncatablePrimes(8)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof truncatablePrimes(8) === 'number');
|
||||
```
|
||||
|
||||
`truncatablePrimes(8)` should return 1986.
|
||||
`truncatablePrimes(8)` deve retornar 1986.
|
||||
|
||||
```js
|
||||
assert(truncatablePrimes(8) == 1986);
|
||||
```
|
||||
|
||||
`truncatablePrimes(9)` should return 5123.
|
||||
`truncatablePrimes(9)` deve retornar 5123.
|
||||
|
||||
```js
|
||||
assert(truncatablePrimes(9) == 5123);
|
||||
```
|
||||
|
||||
`truncatablePrimes(10)` should return 8920.
|
||||
`truncatablePrimes(10)` deve retornar 8920.
|
||||
|
||||
```js
|
||||
assert(truncatablePrimes(10) == 8920);
|
||||
```
|
||||
|
||||
`truncatablePrimes(11)` should return 748317.
|
||||
`truncatablePrimes(11)` deve retornar 748317.
|
||||
|
||||
```js
|
||||
assert(truncatablePrimes(11) == 748317);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3931000cf542c50fea5
|
||||
title: 'Problem 38: Pandigital multiples'
|
||||
title: 'Problema 38: Múltiplos pandigitais'
|
||||
challengeType: 5
|
||||
forumTopicId: 302042
|
||||
dashedName: problem-38-pandigital-multiples
|
||||
@ -8,31 +8,31 @@ dashedName: problem-38-pandigital-multiples
|
||||
|
||||
# --description--
|
||||
|
||||
Take the number 192 and multiply it by each of 1, 2, and 3:
|
||||
Pegue o número 192 e multiplique-o por cada um entre 1, 2 e 3:
|
||||
|
||||
$$\begin{align} 192 × 1 = 192\\\\ 192 × 2 = 384\\\\ 192 × 3 = 576\\\\ \end{align}$$
|
||||
|
||||
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1, 2, 3).
|
||||
Ao concatenar cada produto, chegamos ao total 192384576. Esse resultado possui 9 dígitos e usa todos os número de 1 a 9 pelo menos uma vez. Chamaremos 192384576 o produto concatenado de 192 e (1, 2, 3).
|
||||
|
||||
The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1, 2, 3, 4, 5).
|
||||
O mesmo pode ser alcançado começando por 9 e multiplicando por 1, 2, 3, 4 e 5. O resultado é o pandigital 918273645, que é o produto concatenado de 9 e (1, 2, 3, 4, 5).
|
||||
|
||||
What is the largest 1 to `k` pandigital `k`-digit number that can be formed as the concatenated product of an integer with (1, 2, ..., `n`) where `n` > 1?
|
||||
Qual é o maior número pandigital de 1 a `k` com `k` dígitos que pode ser formado como o produto concatenado de um inteiro com (1, 2, ..., `n`) onde `n` > 1?
|
||||
|
||||
# --hints--
|
||||
|
||||
`pandigitalMultiples(8)` should return a number.
|
||||
`pandigitalMultiples(8)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof pandigitalMultiples(8) === 'number');
|
||||
```
|
||||
|
||||
`pandigitalMultiples(8)` should return `78156234`.
|
||||
`pandigitalMultiples(8)` deve retornar `78156234`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(pandigitalMultiples(8), 78156234);
|
||||
```
|
||||
|
||||
`pandigitalMultiples(9)` should return `932718654`.
|
||||
`pandigitalMultiples(9)` deve retornar `932718654`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(pandigitalMultiples(9), 932718654);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3931000cf542c50fea6
|
||||
title: 'Problem 39: Integer right triangles'
|
||||
title: 'Problema 39: Triângulos retângulo'
|
||||
challengeType: 5
|
||||
forumTopicId: 302054
|
||||
dashedName: problem-39-integer-right-triangles
|
||||
@ -8,39 +8,39 @@ dashedName: problem-39-integer-right-triangles
|
||||
|
||||
# --description--
|
||||
|
||||
If `p` is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
|
||||
Se `p` é o perímetro de um triângulo retângulo e o comprimento de seus lados são números inteiros, {a,b,c}, existem exatamente três soluções para p = 120.
|
||||
|
||||
{20,48,52}, {24,45,51}, {30,40,50}
|
||||
|
||||
For which value of `p` ≤ `n`, is the number of solutions maximized?
|
||||
Para qual valor de `p` ≤ `n`, o número de soluções é maximizado?
|
||||
|
||||
# --hints--
|
||||
|
||||
`intRightTriangles(500)` should return a number.
|
||||
`intRightTriangles(500)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof intRightTriangles(500) === 'number');
|
||||
```
|
||||
|
||||
`intRightTriangles(500)` should return 420.
|
||||
`intRightTriangles(500)` deve retornar 420.
|
||||
|
||||
```js
|
||||
assert(intRightTriangles(500) == 420);
|
||||
```
|
||||
|
||||
`intRightTriangles(800)` should return 720.
|
||||
`intRightTriangles(800)` deve retornar 720.
|
||||
|
||||
```js
|
||||
assert(intRightTriangles(800) == 720);
|
||||
```
|
||||
|
||||
`intRightTriangles(900)` should return 840.
|
||||
`intRightTriangles(900)` deve retornar 840.
|
||||
|
||||
```js
|
||||
assert(intRightTriangles(900) == 840);
|
||||
```
|
||||
|
||||
`intRightTriangles(1000)` should return 840.
|
||||
`intRightTriangles(1000)` deve retornar 840.
|
||||
|
||||
```js
|
||||
assert(intRightTriangles(1000) == 840);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3941000cf542c50fea7
|
||||
title: 'Problem 40: Champernowne''s constant'
|
||||
title: 'Problema 40: Constante de Champernowne'
|
||||
challengeType: 5
|
||||
forumTopicId: 302066
|
||||
dashedName: problem-40-champernownes-constant
|
||||
@ -8,37 +8,37 @@ dashedName: problem-40-champernownes-constant
|
||||
|
||||
# --description--
|
||||
|
||||
An irrational decimal fraction is created by concatenating the positive integers:
|
||||
Uma fração decimal irracional é criada concatenando os números inteiros positivos:
|
||||
|
||||
0.12345678910**1**112131415161718192021...
|
||||
|
||||
It can be seen that the 12<sup>th</sup> digit of the fractional part is 1.
|
||||
Podemos notar que o 12º algarismo da parte fracionária é 1.
|
||||
|
||||
If *d<sub>n</sub>* represents the *n*<sup>th</sup> digit of the fractional part, find the value of the following expression.
|
||||
Se *d<sub>n</sub>* representa o *n*-ésimo dígito da parte fracionária, encontre o valor da expressão a seguir:
|
||||
|
||||
d<sub>1</sub> × d<sub>10</sub> × d<sub>100</sub> × d<sub>1000</sub> × d<sub>10000</sub> × d<sub>100000</sub> × d<sub>1000000</sub>
|
||||
|
||||
# --hints--
|
||||
|
||||
`champernownesConstant(100)` should return a number.
|
||||
`champernownesConstant(100)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof champernownesConstant(100) === 'number');
|
||||
```
|
||||
|
||||
`champernownesConstant(100)` should return 5.
|
||||
`champernownesConstant(100)` deve retornar 5.
|
||||
|
||||
```js
|
||||
assert.strictEqual(champernownesConstant(100), 5);
|
||||
```
|
||||
|
||||
`champernownesConstant(1000)` should return 15.
|
||||
`champernownesConstant(1000)` deve retornar 15.
|
||||
|
||||
```js
|
||||
assert.strictEqual(champernownesConstant(1000), 15);
|
||||
```
|
||||
|
||||
`champernownesConstant(1000000)` should return 210.
|
||||
`champernownesConstant(1000000)` deve retornar 210.
|
||||
|
||||
```js
|
||||
assert.strictEqual(champernownesConstant(1000000), 210);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3951000cf542c50fea8
|
||||
title: 'Problem 41: Pandigital prime'
|
||||
title: 'Problema 41: Número primo pandigital'
|
||||
challengeType: 5
|
||||
forumTopicId: 302078
|
||||
dashedName: problem-41-pandigital-prime
|
||||
@ -8,25 +8,25 @@ dashedName: problem-41-pandigital-prime
|
||||
|
||||
# --description--
|
||||
|
||||
We shall say that an `n`-digit number is pandigital if it makes use of all the digits 1 to `n` exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
|
||||
Dizemos que um número de `n` dígitos é pandigital se ele usar todos os dígitos de 1 a `n` exatamente uma vez. Por exemplo, 2143 é um número pandigital de 4 algarismos e também é um número primo.
|
||||
|
||||
What is the largest `n`-length digit pandigital prime that exists?
|
||||
Qual é o maior número primo pandigital de comprimento `n` que existe?
|
||||
|
||||
# --hints--
|
||||
|
||||
`pandigitalPrime(4)` should return a number.
|
||||
`pandigitalPrime(4)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof pandigitalPrime(4) === 'number');
|
||||
```
|
||||
|
||||
`pandigitalPrime(4)` should return 4231.
|
||||
`pandigitalPrime(4)` deve retornar 4231.
|
||||
|
||||
```js
|
||||
assert(pandigitalPrime(4) == 4231);
|
||||
```
|
||||
|
||||
`pandigitalPrime(7)` should return 7652413.
|
||||
`pandigitalPrime(7)` deve retornar 7652413.
|
||||
|
||||
```js
|
||||
assert(pandigitalPrime(7) == 7652413);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f50c1000cf542c51001e
|
||||
title: 'Problem 415: Titanic sets'
|
||||
title: 'Problema 415: Conjuntos titânicos'
|
||||
challengeType: 5
|
||||
forumTopicId: 302084
|
||||
dashedName: problem-415-titanic-sets
|
||||
@ -8,22 +8,22 @@ dashedName: problem-415-titanic-sets
|
||||
|
||||
# --description--
|
||||
|
||||
A set of lattice points S is called a titanic set if there exists a line passing through exactly two points in S.
|
||||
Um conjunto de pontos de uma rede diagonal $S$ é chamado de conjunto titânico se existir uma linha que passe por exatamente dois pontos em $S$.
|
||||
|
||||
An example of a titanic set is S = {(0, 0), (0, 1), (0, 2), (1, 1), (2, 0), (1, 0)}, where the line passing through (0, 1) and (2, 0) does not pass through any other point in S.
|
||||
Um exemplo de um conjunto titânico é $S = \\{(0, 0), (0, 1), (0, 2), (1, 1), (2, 0), (1, 0)\\}$, onde a linha passando por (0, 1) e (2, 0) não passa por nenhum outro ponto em $S$.
|
||||
|
||||
On the other hand, the set {(0, 0), (1, 1), (2, 2), (4, 4)} is not a titanic set since the line passing through any two points in the set also passes through the other two.
|
||||
Por outro lado, o conjunto {(0, 0), (1, 1), (2, 2), (4, 4)} não é um conjunto titânico, já que a linha que passa por dois pontos quaisquer no conjunto também passa pelos outros dois.
|
||||
|
||||
For any positive integer N, let T(N) be the number of titanic sets S whose every point (x, y) satisfies 0 ≤ x, y ≤ N. It can be verified that T(1) = 11, T(2) = 494, T(4) = 33554178, T(111) mod 108 = 13500401 and T(105) mod 108 = 63259062.
|
||||
Para qualquer inteiro positivo $N$, consideremos que $T(N)$ é o número de conjuntos titânicos $S$ em que cada ponto ($x$, $y$) satisfaz $0 ≤ x$, $y ≤ N$. Pode-se verificar que $T(1) = 11$, $T(2) = 494$, $T(4) = 33\\,554\\,178$, $T(111)\bmod {10}^8 = 13\\,500\\,401$ e $T({10}^5)\bmod {10}^8 = 63\\,259\\,062$.
|
||||
|
||||
Find T(1011) mod 108.
|
||||
Encontre $T({10}^{11})\bmod {10}^8$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler415()` should return 55859742.
|
||||
`titanicSets()` deve retornar `55859742`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler415(), 55859742);
|
||||
assert.strictEqual(titanicSets(), 55859742);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -31,12 +31,12 @@ assert.strictEqual(euler415(), 55859742);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler415() {
|
||||
function titanicSets() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler415();
|
||||
titanicSets();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f50e1000cf542c510020
|
||||
title: 'Problem 416: A frog''s trip'
|
||||
title: 'Problema 416: A viagem de um sapo'
|
||||
challengeType: 5
|
||||
forumTopicId: 302085
|
||||
dashedName: problem-416-a-frogs-trip
|
||||
@ -8,18 +8,20 @@ dashedName: problem-416-a-frogs-trip
|
||||
|
||||
# --description--
|
||||
|
||||
A row of n squares contains a frog in the leftmost square. By successive jumps the frog goes to the rightmost square and then back to the leftmost square. On the outward trip he jumps one, two or three squares to the right, and on the homeward trip he jumps to the left in a similar manner. He cannot jump outside the squares. He repeats the round-trip travel m times.
|
||||
Uma fileira de $n$ quadrados contém um sapo no quadrado mais à esquerda. Em sucessivos pulos, o sapo vai para o quadrado mais à direita e depois volta para o quadrado mais à esquerda. Na viagem de ida, ele pula um, dois ou três quadrados para a direita. Na viagem de volta para casa, ele pula para a esquerda de uma maneira parecida. Ele não pode pular fora dos quadrados. Ele repete a viagem de ida e volta $m$ vezes.
|
||||
|
||||
Let F(m, n) be the number of the ways the frog can travel so that at most one square remains unvisited. For example, F(1, 3) = 4, F(1, 4) = 15, F(1, 5) = 46, F(2, 3) = 16 and F(2, 100) mod 109 = 429619151.
|
||||
Considere que $F(m, n)$ é o número de maneiras pelas quais o sapo pode viajar, sendo que, no máximo, um quadrado pode permanecer sem ser visitado.
|
||||
|
||||
Find the last 9 digits of F(10, 1012).
|
||||
Por exemplo, $F(1, 3) = 4$, $F(1, 4) = 15$, $F(1, 5) = 46$, $F(2, 3) = 16$ e $F(2, 100)\bmod {10}^9 = 429\\,619\\,151$.
|
||||
|
||||
Encontre os últimos 9 dígitos de $F(10, {10}^{12})$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler416()` should return 898082747.
|
||||
`frogsTrip()` deve retornar `898082747`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler416(), 898082747);
|
||||
assert.strictEqual(frogsTrip(), 898082747);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -27,12 +29,12 @@ assert.strictEqual(euler416(), 898082747);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler416() {
|
||||
function frogsTrip() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler416();
|
||||
frogsTrip();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f50d1000cf542c51001f
|
||||
title: 'Problem 417: Reciprocal cycles II'
|
||||
title: 'Problema 417: Dízimas periódicas'
|
||||
challengeType: 5
|
||||
forumTopicId: 302086
|
||||
dashedName: problem-417-reciprocal-cycles-ii
|
||||
@ -8,24 +8,24 @@ dashedName: problem-417-reciprocal-cycles-ii
|
||||
|
||||
# --description--
|
||||
|
||||
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:
|
||||
Em uma fração unitária, o numerador é 1. A representação decimal das frações unitárias com denominadores de 2 a 10 é a seguinte:
|
||||
|
||||
1/2= 0.5 1/3= 0.(3) 1/4= 0.25 1/5= 0.2 1/6= 0.1(6) 1/7= 0.(142857) 1/8= 0.125 1/9= 0.(1) 1/10= 0.1
|
||||
$$\begin{align} & \frac{1}{2} = 0.5 \\\\ & \frac{1}{3} = 0.(3) \\\\ & \frac{1}{4} = 0.25 \\\\ & \frac{1}{5} = 0.2 \\\\ & \frac{1}{6} = 0.1(6) \\\\ & \frac{1}{7} = 0.(142857) \\\\ & \frac{1}{8} = 0.125 \\\\ & \frac{1}{9} = 0.(1) \\\\ & \frac{1}{10} = 0.1 \\\\ \end{align}$$
|
||||
|
||||
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.
|
||||
A expressão $0.1(6)$ significa $0.16666666\dots$, e tem um ciclo recorrente de 1 algarismo. Pode ser visto que $\frac{1}{7}$ tem um ciclo recorrente de 6 dígitos.
|
||||
|
||||
Unit fractions whose denominator has no other prime factors than 2 and/or 5 are not considered to have a recurring cycle. We define the length of the recurring cycle of those unit fractions as 0.
|
||||
Frações unitárias cujo denominador não tem outros fatores primos além de 2 e/ou 5 não são consideradas como tendo um ciclo recorrente. Definimos 0 como o comprimento do ciclo recorrente dessas frações unitárias.
|
||||
|
||||
Let L(n) denote the length of the recurring cycle of 1/n. You are given that ∑L(n) for 3 ≤ n ≤ 1 000 000 equals 55535191115.
|
||||
Considere que $L(n)$ denota o comprimento do ciclo recorrente de $\frac{1}{n}$. Você recebe a informação de que $\sum L(n)$ por $3 ≤ n ≤ 1\\,000\\,000$ é igual a $55\\,535\\,191\\,115$.
|
||||
|
||||
Find ∑L(n) for 3 ≤ n ≤ 100 000 000
|
||||
Calcule $\sum L(n)$ por $3 ≤ n ≤ 100\\,000\\,000$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler417()` should return 446572970925740.
|
||||
`reciprocalCyclesTwo()` deve retornar `446572970925740`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler417(), 446572970925740);
|
||||
assert.strictEqual(reciprocalCyclesTwo(), 446572970925740);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -33,12 +33,12 @@ assert.strictEqual(euler417(), 446572970925740);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler417() {
|
||||
function reciprocalCyclesTwo() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler417();
|
||||
reciprocalCyclesTwo();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f50f1000cf542c510021
|
||||
title: 'Problem 418: Factorisation triples'
|
||||
title: 'Problema 418: Trios de fatoração'
|
||||
challengeType: 5
|
||||
forumTopicId: 302087
|
||||
dashedName: problem-418-factorisation-triples
|
||||
@ -8,22 +8,23 @@ dashedName: problem-418-factorisation-triples
|
||||
|
||||
# --description--
|
||||
|
||||
Let n be a positive integer. An integer triple (a, b, c) is called a factorisation triple of n if: 1 ≤ a ≤ b ≤ c
|
||||
Considere $n$ um inteiro positivo. Um trio de números inteiros ($a$, $b$, $c$) é chamado de trio de fatoração de $n$ se:
|
||||
|
||||
a·b·c = n.
|
||||
- $1 ≤ a ≤ b ≤ c$
|
||||
- $a \times b \times c = n$.
|
||||
|
||||
Define f(n) to be a + b + c for the factorisation triple (a, b, c) of n which minimises c / a. One can show that this triple is unique.
|
||||
Defina $f(n)$ como $a + b + c$ para o trio da fatoração ($a$, $b$, $c$) de $n$ que minimiza $\frac{c}{a}$. Podemos mostrar que esse trio é único.
|
||||
|
||||
For example, f(165) = 19, f(100100) = 142 and f(20!) = 4034872.
|
||||
Por exemplo, $f(165) = 19$, $f(100\\,100) = 142$ e $f(20!) = 4\\,034\\,872$.
|
||||
|
||||
Find f(43!).
|
||||
Encontre $f(43!)$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler418()` should return 1177163565297340400.
|
||||
`factorisationTriples()` deve retornar `1177163565297340400`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler418(), 1177163565297340400);
|
||||
assert.strictEqual(factorisationTriples(), 1177163565297340400);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -31,12 +32,12 @@ assert.strictEqual(euler418(), 1177163565297340400);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler418() {
|
||||
function factorisationTriples() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler418();
|
||||
factorisationTriples();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f5101000cf542c510022
|
||||
title: 'Problem 419: Look and say sequence'
|
||||
title: 'Problema 419: Sequência para olhar e dizer'
|
||||
challengeType: 5
|
||||
forumTopicId: 302088
|
||||
dashedName: problem-419-look-and-say-sequence
|
||||
@ -8,34 +8,41 @@ dashedName: problem-419-look-and-say-sequence
|
||||
|
||||
# --description--
|
||||
|
||||
The look and say sequence goes 1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...
|
||||
A sequência para olhar e dizer é 1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...
|
||||
|
||||
The sequence starts with 1 and all other members are obtained by describing the previous member in terms of consecutive digits.
|
||||
A sequência começa com 1 e todos os outros membros são obtidos descrevendo o membro anterior em termos de dígitos consecutivos.
|
||||
|
||||
It helps to do this out loud:
|
||||
Ajuda ler os dígitos em voz alta:
|
||||
|
||||
1 is 'one one' → 11
|
||||
1 é 'um um' $→ 11$
|
||||
|
||||
11 is 'two ones' → 21
|
||||
11 é 'dois um' $→ 21$
|
||||
|
||||
21 is 'one two and one one' → 1211
|
||||
21 é 'um dois e um um' $→ 1211$
|
||||
|
||||
1211 is 'one one, one two and two ones' → 111221
|
||||
1211 é 'um um, um dois e dois um' $→ 111221$
|
||||
|
||||
111221 is 'three ones, two twos and one one' → 312211
|
||||
111221 is 'três um, dois dois e um um' $→ 312211$
|
||||
|
||||
...
|
||||
|
||||
Define A(n), B(n) and C(n) as the number of ones, twos and threes in the n'th element of the sequence respectively. One can verify that A(40) = 31254, B(40) = 20259 and C(40) = 11625.
|
||||
Defina $A(n)$, $B(n)$ e $C(n)$ como o número de uns, dois e três no $n$'ésimo elemento da sequência, respectivamente. Podemos verificar se $A(40) = 31\\,254$, $B(40) = 20\\,259$ e $C(40) = 11\\,625$.
|
||||
|
||||
Find A(n), B(n) and C(n) for n = 1012. Give your answer modulo 230 and separate your values for A, B and C by a comma. E.g. for n = 40 the answer would be 31254,20259,11625
|
||||
Calcule $A(n)$, $B(n)$ e $C(n)$ para $n = {10}^{12}$. Dê o modulo $2^{30}$ de sua respostas como uma string e separe seus valores para $A$, $B$ e $C$ por uma vírgula. Ex: para $n = 40$, a resposta seria `31254,20259,11625`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler419()` should return 998567458, 1046245404, 43363922.
|
||||
`lookAndSaySequence()` deve retornar uma string.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler419(), 998567458, 1046245404, 43363922);
|
||||
assert(typeof lookAndSaySequence() === 'string');
|
||||
```
|
||||
|
||||
|
||||
`lookAndSaySequence()` deve retornar a string `998567458,1046245404,43363922`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(lookAndSaySequence(), '998567458,1046245404,43363922');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -43,12 +50,12 @@ assert.strictEqual(euler419(), 998567458, 1046245404, 43363922);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler419() {
|
||||
function lookAndSaySequence() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler419();
|
||||
lookAndSaySequence();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3961000cf542c50fea9
|
||||
title: 'Problem 42: Coded triangle numbers'
|
||||
title: 'Problema 42: Números triangulares codificados'
|
||||
challengeType: 5
|
||||
forumTopicId: 302089
|
||||
dashedName: problem-42-coded-triangle-numbers
|
||||
@ -8,41 +8,41 @@ dashedName: problem-42-coded-triangle-numbers
|
||||
|
||||
# --description--
|
||||
|
||||
The `n`<sup>th</sup> term of the sequence of triangle numbers is given by, `tn` = ½`n`(`n`+1); so the first ten triangle numbers are:
|
||||
O `n`-ésimo termo da sequência de números triangulares é dado por, `tn` = ½`n`(`n`+1). Os primeiros dez números triangulares são:
|
||||
|
||||
<div style='margin-left: 4em;'>1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...</div>
|
||||
|
||||
By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is 19 + 11 + 25 = 55 = `t`<sub>10</sub>. If the word value is a triangle number then we shall call the word a triangle word.
|
||||
Ao converter cada letra de uma palavra para o número correspondente a sua posição alfabética e somar esses valores, nós formamos o valor (numérico) da palavra. Por exemplo, o valor da palavra SKY é 19 + 11 + 25 = 55 = `t`<sub>10</sub>. Se o valor da palavra é um número triangular, então vamos chamar a palavra de uma palavra triângulo.
|
||||
|
||||
Using words array of `n`-length, how many are triangle words?
|
||||
Usando o array de palavras de comprimento `n`, quantas são palavras triangulares?
|
||||
|
||||
# --hints--
|
||||
|
||||
`codedTriangleNumbers(1400)` should return a number.
|
||||
`codedTriangleNumbers(1400)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof codedTriangleNumbers(1400) === 'number');
|
||||
```
|
||||
|
||||
`codedTriangleNumbers(1400)` should return 129.
|
||||
`codedTriangleNumbers(1400)` deve retornar 129.
|
||||
|
||||
```js
|
||||
assert(codedTriangleNumbers(1400) == 129);
|
||||
```
|
||||
|
||||
`codedTriangleNumbers(1500)` should return 137.
|
||||
`codedTriangleNumbers(1500)` deve retornar 137.
|
||||
|
||||
```js
|
||||
assert(codedTriangleNumbers(1500) == 137);
|
||||
```
|
||||
|
||||
`codedTriangleNumbers(1600)` should return 141.
|
||||
`codedTriangleNumbers(1600)` deve retornar 141.
|
||||
|
||||
```js
|
||||
assert(codedTriangleNumbers(1600) == 141);
|
||||
```
|
||||
|
||||
`codedTriangleNumbers(1786)` should return 162.
|
||||
`codedTriangleNumbers(1786)` deve retornar 162.
|
||||
|
||||
```js
|
||||
assert(codedTriangleNumbers(1786) == 162);
|
||||
|
@ -23,7 +23,7 @@ Conway forneceu um programa para números primos em FRACTRAN:
|
||||
|
||||
$\\dfrac{17}{91}$, $\\dfrac{78}{85}$, $\\dfrac{19}{51}$, $\\dfrac{23}{38}$, $\\dfrac{29}{33}$, $\\dfrac{77}{29}$, $\\dfrac{95}{23}$, $\\dfrac{77}{19}$, $\\dfrac{1}{17}$, $\\dfrac{11}{13}$, $\\dfrac{13}{11}$, $\\dfrac{15}{14}$, $\\dfrac{15}{2}$, $\\dfrac{55}{1}$
|
||||
|
||||
Começando com $n=2$, este programa em FRACTRAN mudará $n$ para $15=2\\vezes (\\frac{15}{2})$, então $825=15\\vezes (\\frac{55}{1})$, gerando a seguinte sequência de inteiros:
|
||||
Começando com $n=2$, este programa em FRACTRAN mudará $n$ para $15=2\\times (\\frac{15}{2})$, então $825=15\\times (\\frac{55}{1})$, gerando a seguinte sequência de inteiros:
|
||||
|
||||
$2$, $15$, $825$, $725$, $1925$, $2275$, $425$, $390$, $330$, $290$, $770$, $\\ldots$
|
||||
|
||||
|
@ -10,7 +10,7 @@ dashedName: gaussian-elimination
|
||||
|
||||
Escreva uma função para calcular \\(Ax = b\\) usando a eliminação gaussiana e, em seguida, a substituição reversa.
|
||||
|
||||
\\(A\\) sendo uma matriz \\(n \\vezes n\\). Além disso, \\(x\\) e \\(b\\) são vetores \\(n\\) por 1.
|
||||
\\(A\\) sendo uma matriz \\(n \\times n\\). Além disso, \\(x\\) e \\(b\\) são vetores \\(n\\) por 1.
|
||||
|
||||
Para melhorar a precisão, use pivô parcial e escala.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7eb1
|
||||
title: Identity matrix
|
||||
title: Matriz identidade
|
||||
challengeType: 5
|
||||
forumTopicId: 302290
|
||||
dashedName: identity-matrix
|
||||
@ -8,7 +8,7 @@ dashedName: identity-matrix
|
||||
|
||||
# --description--
|
||||
|
||||
An *identity matrix* is a square matrix of size \\( n \\times n \\), where the diagonal elements are all `1`s (ones), and all the other elements are all `0`s (zeroes).
|
||||
Uma *matriz identidade* é uma matriz quadrada de tamanho \\( n \\times n \\), onde os elementos diagonais são todos `1` (um) e todos os outros elementos são `0`(zero).
|
||||
|
||||
<ul>
|
||||
<li style='list-style: none;'>\(\displaystyle I_{n}=\begin{bmatrix} 1 & 0 & 0 \cr 0 & 1 & 0 \cr 0 & 0 & 1 \cr \end{bmatrix}\)</li>
|
||||
@ -16,41 +16,41 @@ An *identity matrix* is a square matrix of size \\( n \\times n \\), where the d
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that takes a number `n` as a parameter and returns the identity matrix of order \\( n \\times n \\).
|
||||
Escreva uma função que recebe um número `n` como um parâmetro e retorna a matriz identidade de ordem \\( n \\times n \\).
|
||||
|
||||
# --hints--
|
||||
|
||||
`idMatrix` should be a function.
|
||||
`idMatrix` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof idMatrix == 'function');
|
||||
```
|
||||
|
||||
`idMatrix(1)` should return an array.
|
||||
`idMatrix(1)` deve retornar um array.
|
||||
|
||||
```js
|
||||
assert(Array.isArray(idMatrix(1)));
|
||||
```
|
||||
|
||||
`idMatrix(1)` should return `[ [ 1 ] ]`.
|
||||
`idMatrix(1)` deve retornar `[ [ 1 ] ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(idMatrix(1), results[0]);
|
||||
```
|
||||
|
||||
`idMatrix(2)` should return `[ [ 1, 0 ], [ 0, 1 ] ]`.
|
||||
`idMatrix(2)` deve retornar `[ [ 1, 0 ], [ 0, 1 ] ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(idMatrix(2), results[1]);
|
||||
```
|
||||
|
||||
`idMatrix(3)` should return `[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]`.
|
||||
`idMatrix(3)` deve retornar `[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(idMatrix(3), results[2]);
|
||||
```
|
||||
|
||||
`idMatrix(4)` should return `[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ]`.
|
||||
`idMatrix(4)` deve retornar `[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(idMatrix(4), results[3]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7ec1
|
||||
title: Iterated digits squaring
|
||||
title: Elevar ao quadrado os dígitos iterados
|
||||
challengeType: 5
|
||||
forumTopicId: 302291
|
||||
dashedName: iterated-digits-squaring
|
||||
@ -8,7 +8,7 @@ dashedName: iterated-digits-squaring
|
||||
|
||||
# --description--
|
||||
|
||||
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89:
|
||||
Se você somar o quadrado dos dígitos de um número natural (um número inteiro maior que zero), você sempre terminará com 1 ou 89:
|
||||
|
||||
<pre>15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89
|
||||
7 -> 49 -> 97 -> 130 -> 10 -> 1
|
||||
@ -16,53 +16,53 @@ If you add the square of the digits of a Natural number (an integer bigger than
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that takes a number as a parameter and returns 1 or 89 after performing the mentioned process.
|
||||
Escreva uma função que receba um número na forma de um parâmetro e retorne 1 ou 89 depois de executar o processo mencionado.
|
||||
|
||||
# --hints--
|
||||
|
||||
`iteratedSquare` should be a function.
|
||||
`iteratedSquare` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof iteratedSquare == 'function');
|
||||
```
|
||||
|
||||
`iteratedSquare(4)` should return a number.
|
||||
`iteratedSquare(4)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof iteratedSquare(4) == 'number');
|
||||
```
|
||||
|
||||
`iteratedSquare(4)` should return `89`.
|
||||
`iteratedSquare(4)` deve retornar `89`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(4), 89);
|
||||
```
|
||||
|
||||
`iteratedSquare(7)` should return `1`.
|
||||
`iteratedSquare(7)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(7), 1);
|
||||
```
|
||||
|
||||
`iteratedSquare(15)` should return `89`.
|
||||
`iteratedSquare(15)` deve retornar `89`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(15), 89);
|
||||
```
|
||||
|
||||
`iteratedSquare(20)` should return `89`.
|
||||
`iteratedSquare(20)` deve retornar `89`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(20), 89);
|
||||
```
|
||||
|
||||
`iteratedSquare(70)` should return `1`.
|
||||
`iteratedSquare(70)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(70), 1);
|
||||
```
|
||||
|
||||
`iteratedSquare(100)` should return `1`.
|
||||
`iteratedSquare(100)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.equal(iteratedSquare(100), 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7ec2
|
||||
title: Jaro distance
|
||||
title: Distância de Jaro
|
||||
challengeType: 5
|
||||
forumTopicId: 302292
|
||||
dashedName: jaro-distance
|
||||
@ -8,28 +8,28 @@ dashedName: jaro-distance
|
||||
|
||||
# --description--
|
||||
|
||||
The Jaro distance is a measure of similarity between two strings. The higher the Jaro distance for two strings is, the more similar the strings are. The score is normalized such that `0` equates to no similarity and `1` is an exact match.
|
||||
A distância de Jaro é uma medida de semelhança entre duas strings. Quanto maior a distância de Jaro entre as duas strings, mais parecidas elas são. A pontuação é normalizada, de modo que `0` é igual a nenhuma similaridade e `1` é uma correspondência exata.
|
||||
|
||||
**Definition**
|
||||
**Definição**
|
||||
|
||||
The Jaro distance \\( d_j \\) of two given strings \\(s_1\\) and \\(s_2\\) is
|
||||
A distância de Jaro \\( d_j \\) de duas strings fornecidas \\(s_1\\) e \\(s_2\\) é
|
||||
|
||||
\\begin{align}d_j = \\begin{cases}0& & \\text{if }m=0 \\\\\\\\{\\frac {1}{3}}\\left({\\frac {m}{|s\_{1}|}}+{\\frac {m}{|s\_{2}|}}+{\\frac {m-t}{m}}\\right)& & \\text{otherwise}\\end{cases}\\end{align}
|
||||
|
||||
Where:
|
||||
Onde:
|
||||
|
||||
<ul>
|
||||
<li>\(m\) is the number of <i>matching characters</i>;</li>
|
||||
<li> \(t\) is half the number of <i>transpositions</i>.</li>
|
||||
<li>\(m\) é o número de <i>caracteres correspondentes</i>;</li>
|
||||
<li> \(t\) é a metade do número de <i>transposições</i>.</li>
|
||||
</ul>
|
||||
|
||||
Two characters from \\(s_1\\) and \\(s_2\\) respectively, are considered *matching* only if they are the same and not farther than \\(\\left\\lfloor\\frac{\\max(|s_1|,|s_2|)}{2}\\right\\rfloor-1\\).
|
||||
Dois caracteres de \\(s_1\\) e \\(s_2\\), respectivamente, são considerados *correspondentes* somente se forem iguais e não mais distante do que \\(\\left\\lfloor\\frac{\\max(|s_1|,|s_2|)}{2}\\right\\rfloor-1\\).
|
||||
|
||||
Each character of \\(s_1\\) is compared with all its matching characters in \\(s_2\\) . The number of matching (but different sequence order) characters divided by 2 defines the number of *transpositions*.
|
||||
Cada caractere de \\(s_1\\) é comparado com todos os seus caracteres correspondentes em \\(s_2\\) . O número de caracteres correspondentes (mas em ordem sequencial diferente) dividido por 2 define o número de *transposições*.
|
||||
|
||||
**Example**
|
||||
**Exemplo**
|
||||
|
||||
Given the strings \\(s_1\\) *DWAYNE* and \\(s_2\\) *DUANE* we find:
|
||||
Dadas as strings \\(s_1\\) *DWAYNE* e \\(s_2\\) *DUANE*, encontramos:
|
||||
|
||||
<ul>
|
||||
<li>\(m = 4\)</li>
|
||||
@ -38,51 +38,51 @@ Given the strings \\(s_1\\) *DWAYNE* and \\(s_2\\) *DUANE* we find:
|
||||
<li>\(t = 0\)</li>
|
||||
</ul>
|
||||
|
||||
We find a Jaro score of: \\(d_j = \\frac{1}{3}\\left(\\frac{4}{6} + \\frac{4}{5} + \\frac{4-0}{4}\\right) = 0.822\\).
|
||||
Encontramos uma pontuação de Jaro de: \\(d_j = \\frac{1}{3}\\left(\\frac{4}{6} + \\frac{4}{5} + \\frac{4-0}{4}\\right) = 0.822\\).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function a that takes two strings as parameters and returns the associated Jaro distance.
|
||||
Escreva uma função que receba duas strings como parâmetros e retorne a distância de Jaro associada.
|
||||
|
||||
# --hints--
|
||||
|
||||
`jaro` should be a function.
|
||||
`jaro` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof jaro == 'function');
|
||||
```
|
||||
|
||||
`jaro("MARTHA", "MARHTA")` should return a number.
|
||||
`jaro("MARTHA", "MARHTA")` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof jaro('MARTHA', 'MARHTA') == 'number');
|
||||
```
|
||||
|
||||
`jaro("MARTHA", "MARHTA")` should return `0.9444444444444445`.
|
||||
`jaro("MARTHA", "MARHTA")` deve retornar `0.9444444444444445`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('MARTHA', 'MARHTA'), 0.9444444444444445);
|
||||
```
|
||||
|
||||
`jaro("DIXON", "DICKSONX")` should return `0.7666666666666666`.
|
||||
`jaro("DIXON", "DICKSONX")` deve retornar `0.7666666666666666`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('DIXON', 'DICKSONX'), 0.7666666666666666);
|
||||
```
|
||||
|
||||
`jaro("JELLYFISH", "SMELLYFISH")` should return `0.8962962962962964`.
|
||||
`jaro("JELLYFISH", "SMELLYFISH")` deve retornar `0.8962962962962964`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('JELLYFISH', 'SMELLYFISH'), 0.8962962962962964);
|
||||
```
|
||||
|
||||
`jaro("HELLOS", "CHELLO")` should return `0.888888888888889`.
|
||||
`jaro("HELLOS", "CHELLO")` deve retornar `0.888888888888889`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('HELLOS', 'CHELLO'), 0.888888888888889);
|
||||
```
|
||||
|
||||
`jaro("ABCD", "BCDA")` should return `0.8333333333333334`.
|
||||
`jaro("ABCD", "BCDA")` deve retornar `0.8333333333333334`.
|
||||
|
||||
```js
|
||||
assert.equal(jaro('ABCD', 'BCDA'), 0.8333333333333334);
|
||||
|
@ -8,55 +8,55 @@ dashedName: jortsort
|
||||
|
||||
# --description--
|
||||
|
||||
jortSort is a sorting toolset that makes the user do the work and guarantees efficiency because you don't have to sort ever again. It was originally presented by Jenn "Moneydollars" Schiffer at the prestigious [JSConf](https://www.youtube.com/watch?v=pj4U_W0OFoE).
|
||||
jortSort é um conjunto de ferramentas de ordenação que faz com que o usuário faça o trabalho e garante a eficiência porque você não tem que organizar novamente. Ele foi apresentado originalmente por Jenn "Moneydollars" Schiffer na prestigiada conferência [JSConf](https://www.youtube.com/watch?v=pj4U_W0OFoE).
|
||||
|
||||
jortSort should be a function that takes a single array of comparable objects as its argument. It then sorts the array in ascending order and compares the sorted array to the originally provided array. If the arrays match (i.e. the original array was already sorted), the function returns true. If the arrays do not match (i.e. the original array was not sorted), the function returns false.
|
||||
jortSort deve ser uma função que recebe um único array de objetos comparáveis como argumento. Ela ordena o array em ordem ascendente e compara o array ordenado ao array fornecido inicialmente. Se os arrays corresponderem (ou seja, se o array original já foi ordenado), a função retorna true. Se os arrays não corresponderem (ou seja, se o array original não estiver ordenado), a função retorna false.
|
||||
|
||||
# --hints--
|
||||
|
||||
`jortsort` should be a function.
|
||||
`jortsort` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof jortsort == 'function');
|
||||
```
|
||||
|
||||
`jortsort([1,2,3,4,5])` should return a boolean.
|
||||
`jortsort([1,2,3,4,5])` deve retornar um booleano.
|
||||
|
||||
```js
|
||||
assert(typeof jortsort([1, 2, 3, 4, 5]) == 'boolean');
|
||||
```
|
||||
|
||||
`jortsort([1,2,3,4,5])` should return `true`.
|
||||
`jortsort([1,2,3,4,5])` deve retornar `true`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([1, 2, 3, 4, 5]), true);
|
||||
```
|
||||
|
||||
`jortsort([1,2,13,4,5])` should return `false`.
|
||||
`jortsort([1,2,13,4,5])` deve retornar `false`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([1, 2, 13, 4, 5]), false);
|
||||
```
|
||||
|
||||
`jortsort([12,4,51,2,4])` should return `false`.
|
||||
`jortsort([12,4,51,2,4])` deve retornar `false`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([12, 4, 51, 2, 4]), false);
|
||||
```
|
||||
|
||||
`jortsort([1,2])` should return `true`.
|
||||
`jortsort([1,2])` deve retornar `true`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([1, 2]), true);
|
||||
```
|
||||
|
||||
`jortsort([5,4,3,2,1])` should return `false`.
|
||||
`jortsort([5,4,3,2,1])` deve retornar `false`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([5, 4, 3, 2, 1]), false);
|
||||
```
|
||||
|
||||
`jortsort([1,1,1,1,1])` should return `true`.
|
||||
`jortsort([1,1,1,1,1])` deve retornar `true`.
|
||||
|
||||
```js
|
||||
assert.equal(jortsort([1, 1, 1, 1, 1]), true);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7ec5
|
||||
title: Josephus problem
|
||||
title: O problema de Josephus
|
||||
challengeType: 5
|
||||
forumTopicId: 302294
|
||||
dashedName: josephus-problem
|
||||
@ -8,65 +8,65 @@ dashedName: josephus-problem
|
||||
|
||||
# --description--
|
||||
|
||||
[Josephus problem](https://en.wikipedia.org/wiki/Josephus problem) is a math puzzle with a grim description: $n$ prisoners are standing on a circle, sequentially numbered from $0$ to $n-1$.
|
||||
O [problema de Josephus](https://en.wikipedia.org/wiki/Josephus problem) é um desafio de matemática com uma descrição macabra: $n$ prisoneiros estão de pé, em círculo, sequencialmente numerados de $0$ a $n-1$.
|
||||
|
||||
An executioner walks along the circle, starting from prisoner $0$, removing every $k$-th prisoner and killing him.
|
||||
Um carrasco caminha pelo círculo, começando pelo prisioneiro $0$, removendo cada $k$-ésimo prisioneiro e matando-o.
|
||||
|
||||
As the process goes on, the circle becomes smaller and smaller, until only one prisoner remains, who is then freed.
|
||||
À medida que o processo avança, o círculo torna-se cada vez menor, até ficar apenas um prisioneiro, que é depois libertado.
|
||||
|
||||
For example, if there are $n=5$ prisoners and $k=2$, the order the prisoners are killed in (let's call it the "killing sequence") will be 1, 3, 0, and 4, and the survivor will be #2.
|
||||
Por exemplo, se houver $n=5$ prisioneiros e $k=2$, a ordem em que os prisioneiros são mortos (vamos chamá-la de "sequência de morte") será 1, 3, 0 e 4. O sobrevivente, então, será o nº 2.
|
||||
|
||||
Given any $n, k > 0$, find out which prisoner will be the final survivor.
|
||||
Dado qualquer $n, sendo k > 0$, descubra qual prisioneiro será o sobrevivente ao final.
|
||||
|
||||
In one such incident, there were 41 prisoners and every 3<sup>rd</sup> prisoner was being killed ($k=3$).
|
||||
Em um incidente deste tipo, havia 41 prisoneiros e o 3<sup>o</sup> prisioneiro na sequência era morto ($k=3$).
|
||||
|
||||
Among them was a clever chap name Josephus who worked out the problem, stood at the surviving position, and lived on to tell the tale.
|
||||
Entre eles, havia um homem inteligente, chamado Josephus, que desvendou o problema, ficou na posição do sobrevivente e viveu para contar a história.
|
||||
|
||||
Which number was he?
|
||||
Qual era o número dele?
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that takes the initial number of prisoners and 'k' as parameter and returns the number of the prisoner that survives.
|
||||
Escreva uma função que recebe o número inicial de prisioneiros e 'k' como parâmetros, devolvendo o número do prisioneiro que sobrevive.
|
||||
|
||||
# --hints--
|
||||
|
||||
`josephus` should be a function.
|
||||
`josephus` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof josephus == 'function');
|
||||
```
|
||||
|
||||
`josephus(30,3)` should return a number.
|
||||
`josephus(30,3)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof josephus(30, 3) == 'number');
|
||||
```
|
||||
|
||||
`josephus(30,3)` should return `28`.
|
||||
`josephus(30,3)` deve retornar `28`.
|
||||
|
||||
```js
|
||||
assert.equal(josephus(30, 3), 28);
|
||||
```
|
||||
|
||||
`josephus(30,5)` should return `2`.
|
||||
`josephus(30,5)` deve retornar `2`.
|
||||
|
||||
```js
|
||||
assert.equal(josephus(30, 5), 2);
|
||||
```
|
||||
|
||||
`josephus(20,2)` should return `8`.
|
||||
`josephus(20,2)` deve retornar `8`.
|
||||
|
||||
```js
|
||||
assert.equal(josephus(20, 2), 8);
|
||||
```
|
||||
|
||||
`josephus(17,6)` should return `1`.
|
||||
`josephus(17,6)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.equal(josephus(17, 6), 1);
|
||||
```
|
||||
|
||||
`josephus(29,4)` should return `1`.
|
||||
`josephus(29,4)` deve retornar `1`.
|
||||
|
||||
```js
|
||||
assert.equal(josephus(29, 4), 1);
|
||||
|
Reference in New Issue
Block a user