fix(curriculum): clean-up Project Euler 221-240 (#42839)

* fix: clean-up Project Euler 221-240

* fix: corrections from review

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
gikf
2021-07-15 14:26:34 +02:00
committed by GitHub
parent 30c22d1fb3
commit a9418a1fe9
20 changed files with 233 additions and 173 deletions

View File

@ -8,20 +8,25 @@ dashedName: problem-221-alexandrian-integers
# --description--
We shall call a positive integer A an "Alexandrian integer", if there exist integers p, q, r such that: A = p · q · r and 1/A = 1/p + 1/q + 1/r
We shall call a positive integer $A$ an "Alexandrian integer", if there exist integers $p$, $q$, $r$ such that:
<!-- TODO Use MathJax -->
$$A = p \times q \times r$$
For example, 630 is an Alexandrian integer (p = 5, q = 7, r = 18). In fact, 630 is the 6th Alexandrian integer, the first 6 Alexandrian integers being: 6, 42, 120, 156, 420 and 630.
and
$$\frac{1}{A} = \frac{1}{p} + \frac{1}{q} + \frac{1}{r}$$
For example, 630 is an Alexandrian integer ($p = 5$, $q = 7$, $r = 18$). In fact, 630 is the 6th Alexandrian integer, the first 6 Alexandrian integers being: 6, 42, 120, 156, 420 and 630.
Find the 150000th Alexandrian integer.
# --hints--
`euler221()` should return 1884161251122450.
`alexandrianIntegers()` should return `1884161251122450`.
```js
assert.strictEqual(euler221(), 1884161251122450);
assert.strictEqual(alexandrianIntegers(), 1884161251122450);
```
# --seed--
@ -29,12 +34,12 @@ assert.strictEqual(euler221(), 1884161251122450);
## --seed-contents--
```js
function euler221() {
function alexandrianIntegers() {
return true;
}
euler221();
alexandrianIntegers();
```
# --solutions--

View File

@ -10,14 +10,14 @@ dashedName: problem-222-sphere-packing
What is the length of the shortest pipe, of internal radius 50mm, that can fully contain 21 balls of radii 30mm, 31mm, ..., 50mm?
Give your answer in micrometres (10-6 m) rounded to the nearest integer.
Give your answer in micrometres (${10}^{-6}$ m) rounded to the nearest integer.
# --hints--
`euler222()` should return 1590933.
`spherePacking()` should return `1590933`.
```js
assert.strictEqual(euler222(), 1590933);
assert.strictEqual(spherePacking(), 1590933);
```
# --seed--
@ -25,12 +25,12 @@ assert.strictEqual(euler222(), 1590933);
## --seed-contents--
```js
function euler222() {
function spherePacking() {
return true;
}
euler222();
spherePacking();
```
# --solutions--

View File

@ -8,16 +8,16 @@ dashedName: problem-223-almost-right-angled-triangles-i
# --description--
Let us call an integer sided triangle with sides a ≤ b ≤ c barely acute if the sides satisfy a2 + b2 = c2 + 1.
Let us call an integer sided triangle with sides $a ≤ b ≤ c$ barely acute if the sides satisfy $a^2 + b^2 = c^2 + 1$.
How many barely acute triangles are there with perimeter ≤ 25,000,000?
How many barely acute triangles are there with perimeter $≤ 25\\,000\\,000$?
# --hints--
`euler223()` should return 61614848.
`almostRightAngledTrianglesOne()` should return `61614848`.
```js
assert.strictEqual(euler223(), 61614848);
assert.strictEqual(almostRightAngledTrianglesOne(), 61614848);
```
# --seed--
@ -25,12 +25,12 @@ assert.strictEqual(euler223(), 61614848);
## --seed-contents--
```js
function euler223() {
function almostRightAngledTrianglesOne() {
return true;
}
euler223();
almostRightAngledTrianglesOne();
```
# --solutions--

View File

@ -8,16 +8,16 @@ dashedName: problem-224-almost-right-angled-triangles-ii
# --description--
Let us call an integer sided triangle with sides a ≤ b ≤ c barely obtuse if the sides satisfy a2 + b2 = c2 - 1.
Let us call an integer sided triangle with sides $a ≤ b ≤ c$ barely obtuse if the sides satisfy $a^2 + b^2 = c^2 - 1$.
How many barely obtuse triangles are there with perimeter ≤ 75,000,000?
How many barely obtuse triangles are there with perimeter $≤ 75\\,000\\,000$?
# --hints--
`euler224()` should return 4137330.
`almostRightAngledTrianglesTwo()` should return `4137330`.
```js
assert.strictEqual(euler224(), 4137330);
assert.strictEqual(almostRightAngledTrianglesTwo(), 4137330);
```
# --seed--
@ -25,12 +25,12 @@ assert.strictEqual(euler224(), 4137330);
## --seed-contents--
```js
function euler224() {
function almostRightAngledTrianglesTwo() {
return true;
}
euler224();
almostRightAngledTrianglesTwo();
```
# --solutions--

View File

@ -10,18 +10,18 @@ dashedName: problem-225-tribonacci-non-divisors
The sequence 1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201 ...
is defined by T1 = T2 = T3 = 1 and Tn = Tn-1 + Tn-2 + Tn-3.
is defined by $T_1 = T_2 = T_3 = 1$ and $T_n = T_{n - 1} + T_{n - 2} + T_{n - 3}$.
It can be shown that 27 does not divide any terms of this sequence. In fact, 27 is the first odd number with this property.
Find the 124th odd number that does not divide any terms of the above sequence.
Find the ${124}^{\text{th}}$ odd number that does not divide any terms of the above sequence.
# --hints--
`euler225()` should return 2009.
`tribonacciNonDivisors()` should return `2009`.
```js
assert.strictEqual(euler225(), 2009);
assert.strictEqual(tribonacciNonDivisors(), 2009);
```
# --seed--
@ -29,12 +29,12 @@ assert.strictEqual(euler225(), 2009);
## --seed-contents--
```js
function euler225() {
function tribonacciNonDivisors() {
return true;
}
euler225();
tribonacciNonDivisors();
```
# --solutions--

View File

@ -8,20 +8,22 @@ dashedName: problem-226-a-scoop-of-blancmange
# --description--
The blancmange curve is the set of points (x,y) such that 0 ≤ x ≤ 1 and ,where s(x) = the distance from x to the nearest integer.
The blancmange curve is the set of points ($x$,$y$) such that $0 ≤ x ≤ 1$ and $\displaystyle y = \sum_{n = 0}^{\infty} \frac{s(2^nx)}{2^n}$, where $s(x)$ is the distance from $x$ to the nearest integer.
The area under the blancmange curve is equal to ½, shown in pink in the diagram below.
The area under the blancmange curve is equal to $\frac{1}{2}$, shown in pink in the diagram below.
Let C be the circle with centre (¼,½) and radius ¼, shown in black in the diagram.
<img class="img-responsive center-block" alt="diagram of blancmange curve, with circle C shown on diagram" src="https://cdn.freecodecamp.org/curriculum/project-euler/a-scoop-of-blancmange.gif" style="background-color: white; padding: 10px;">
What area under the blancmange curve is enclosed by C?Give your answer rounded to eight decimal places in the form 0.abcdefgh
Let $C$ be the circle with centre ($\frac{1}{4}$,$\frac{1}{2}$) and radius $\frac{1}{4}$, shown in black in the diagram.
What area under the blancmange curve is enclosed by $C$? Give your answer rounded to eight decimal places in the form 0.abcdefgh
# --hints--
`euler226()` should return 0.11316017.
`scoopOfBlancmange()` should return `0.11316017`.
```js
assert.strictEqual(euler226(), 0.11316017);
assert.strictEqual(scoopOfBlancmange(), 0.11316017);
```
# --seed--
@ -29,12 +31,12 @@ assert.strictEqual(euler226(), 0.11316017);
## --seed-contents--
```js
function euler226() {
function scoopOfBlancmange() {
return true;
}
euler226();
scoopOfBlancmange();
```
# --solutions--

View File

@ -10,16 +10,24 @@ dashedName: problem-227-the-chase
"The Chase" is a game played with two dice and an even number of players.
The players sit around a table; the game begins with two opposite players having one die each. On each turn, the two players with a die roll it. If a player rolls a 1, he passes the die to his neighbour on the left; if he rolls a 6, he passes the die to his neighbour on the right; otherwise, he keeps the die for the next turn. The game ends when one player has both dice after they have been rolled and passed; that player has then lost.
The players sit around a table; the game begins with two opposite players having one die each. On each turn, the two players with a die roll it.
If the player rolls a 1, he passes the die to his neighbour on the left.
If the player rolls a 6, he passes the die to his neighbour on the right.
Otherwise, he keeps the die for the next turn.
The game ends when one player has both dice after they have been rolled and passed; that player has then lost.
In a game with 100 players, what is the expected number of turns the game lasts? Give your answer rounded to ten significant digits.
# --hints--
`euler227()` should return 3780.618622.
`theChase()` should return `3780.618622`.
```js
assert.strictEqual(euler227(), 3780.618622);
assert.strictEqual(theChase(), 0.618622);
```
# --seed--
@ -27,12 +35,12 @@ assert.strictEqual(euler227(), 3780.618622);
## --seed-contents--
```js
function euler227() {
function theChase() {
return true;
}
euler227();
theChase();
```
# --solutions--

View File

@ -8,34 +8,29 @@ dashedName: problem-228-minkowski-sums
# --description--
<!-- TODO Use MathJax and re-write from projecteuler.net -->
Let $S_n$ be the regular $n$-sided polygon or shape whose vertices $v_k (k = 1, 2, \ldots, n)$ have coordinates:
Let Sn be the regular n-sided polygon or shape whose vertices
$$\begin{align}
& x_k = cos(\frac{2k - 1}{n} × 180°) \\\\
& y_k = sin(\frac{2k - 1}{n} × 180°)
\end{align}$$
vk (k = 1,2,…,n) have coordinates:
Each $S_n$ is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior.
xk = cos( 2k-1/n ×180° )
The Minkowski sum, $S + T$, of two shapes $S$ and $T$ is the result of adding every point in $S$ to every point in $T$, where point addition is performed coordinate-wise: $(u, v) + (x, y) = (u + x, v + y)$.
yk = sin( 2k-1/n ×180° )
For example, the sum of $S_3$ and $S_4$ is the six-sided shape shown in pink below:
Each Sn is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior.
<img class="img-responsive center-block" alt="image showing S_3, S_4 and S_3 + S_4" src="https://cdn.freecodecamp.org/curriculum/project-euler/minkowski-sums.png" style="background-color: white; padding: 10px;">
The Minkowski sum, S+T, of two shapes S and T is the result of
adding every point in S to every point in T, where point addition is performed coordinate-wise:
(u, v) + (x, y) = (u+x, v+y).
For example, the sum of S3 and S4 is the six-sided shape shown in pink below:
How many sides does S1864 + S1865 + … + S1909 have?
How many sides does $S_{1864} + S_{1865} + \ldots + S_{1909}$ have?
# --hints--
`euler228()` should return 86226.
`minkowskiSums()` should return `86226`.
```js
assert.strictEqual(euler228(), 86226);
assert.strictEqual(minkowskiSums(), 86226);
```
# --seed--
@ -43,12 +38,12 @@ assert.strictEqual(euler228(), 86226);
## --seed-contents--
```js
function euler228() {
function minkowskiSums() {
return true;
}
euler228();
minkowskiSums();
```
# --solutions--

View File

@ -10,26 +10,36 @@ dashedName: problem-229-four-representations-using-squares
Consider the number 3600. It is very special, because
3600 = 482 + 362 3600 = 202 + 2×402 3600 = 302 + 3×302 3600 = 452 + 7×152
$$\begin{align}
& 3600 = {48}^2 + {36}^2 \\\\
& 3600 = {20}^2 + {2×40}^2 \\\\
& 3600 = {30}^2 + {3×30}^2 \\\\
& 3600 = {45}^2 + {7×15}^2 \\\\
\end{align}$$
Similarly, we find that 88201 = 992 + 2802 = 2872 + 2×542 = 2832 + 3×522 = 1972 + 7×842.
Similarly, we find that $88201 = {99}^2 + {280}^2 = {287}^2 + 2 × {54}^2 = {283}^2 + 3 × {52}^2 = {197}^2 + 7 × {84}^2$.
In 1747, Euler proved which numbers are representable as a sum of two squares. We are interested in the numbers n which admit representations of all of the following four types:
In 1747, Euler proved which numbers are representable as a sum of two squares. We are interested in the numbers $n$ which admit representations of all of the following four types:
n = a12 + b12n = a22 + 2 b22n = a32 + 3 b32n = a72 + 7 b72,
$$\begin{align}
& n = {a_1}^2 + {b_1}^2 \\\\
& n = {a_2}^2 + 2{b_2}^2 \\\\
& n = {a_3}^2 + 3{b_3}^2 \\\\
& n = {a_7}^2 + 7{b_7}^2 \\\\
\end{align}$$
where the ak and bk are positive integers.
where the $a_k$ and $b_k$ are positive integers.
There are 75373 such numbers that do not exceed 107.
There are 75373 such numbers that do not exceed ${10}^7$.
How many such numbers are there that do not exceed 2×109?
How many such numbers are there that do not exceed $2 × {10}^9$?
# --hints--
`euler229()` should return 11325263.
`representationsUsingSquares()` should return `11325263`.
```js
assert.strictEqual(euler229(), 11325263);
assert.strictEqual(representationsUsingSquares(), 11325263);
```
# --seed--
@ -37,12 +47,12 @@ assert.strictEqual(euler229(), 11325263);
## --seed-contents--
```js
function euler229() {
function representationsUsingSquares() {
return true;
}
euler229();
representationsUsingSquares();
```
# --solutions--

View File

@ -8,32 +8,48 @@ dashedName: problem-230-fibonacci-words
# --description--
For any two strings of digits, A and B, we define FA,B to be the sequence (A,B,AB,BAB,ABBAB,...) in which each term is the concatenation of the previous two.
For any two strings of digits, $A$ and $B$, we define $F_{A,B}$ to be the sequence ($A, B, AB, BAB, ABBAB, \ldots$) in which each term is the concatenation of the previous two.
Further, we define DA,B(n) to be the nth digit in the first term of FA,B that contains at least n digits.
Further, we define $D_{A,B}(n)$ to be the $n^{\text{th}}$ digit in the first term of $F_{A,B}$ that contains at least $n$ digits.
Example:
Let A=1415926535, B=8979323846. We wish to find DA,B(35), say.
Let $A = 1\\,415\\,926\\,535$, $B = 8\\,979\\,323\\,846$. We wish to find $D_{A,B}(35)$, say.
The first few terms of FA,B are: 1415926535 8979323846 14159265358979323846 897932384614159265358979323846 14159265358979323846897932384614159265358979323846
The first few terms of $F_{A,B}$ are:
Then DA,B(35) is the 35th digit in the fifth term, which is 9.
$$\begin{align}
& 1\\,415\\,926\\,535 \\\\
& 8\\,979\\,323\\,846 \\\\
& 14\\,159\\,265\\,358\\,979\\,323\\,846 \\\\
& 897\\,932\\,384\\,614\\,159\\,265\\,358\\,979\\,323\\,846 \\\\
& 14\\,159\\,265\\,358\\,979\\,323\\,846\\,897\\,932\\,384\\,614\\,15\color{red}{9}\\,265\\,358\\,979\\,323\\,846
\end{align}$$
Now we use for A the first 100 digits of π behind the decimal point: 14159265358979323846264338327950288419716939937510 58209749445923078164062862089986280348253421170679
Then $D_{A,B}(35)$ is the ${35}^{\text{th}}$ digit in the fifth term, which is 9.
and for B the next hundred digits:
Now we use for $A$ the first 100 digits of $π$ behind the decimal point:
82148086513282306647093844609550582231725359408128 48111745028410270193852110555964462294895493038196 .
$$\begin{align}
& 14\\,159\\,265\\,358\\,979\\,323\\,846\\,264\\,338\\,327\\,950\\,288\\,419\\,716\\,939\\,937\\,510 \\\\
& 58\\,209\\,749\\,445\\,923\\,078\\,164\\,062\\,862\\,089\\,986\\,280\\,348\\,253\\,421\\,170\\,679
\end{align}$$
Find ∑n = 0,1,...,17 10n× DA,B((127+19n)×7n) .
and for $B$ the next hundred digits:
$$\begin{align}
& 82\\,148\\,086\\,513\\,282\\,306\\,647\\,093\\,844\\,609\\,550\\,582\\,231\\,725\\,359\\,408\\,128 \\\\
& 48\\,111\\,745\\,028\\,410\\,270\\,193\\,852\\,110\\,555\\,964\\,462\\,294\\,895\\,493\\,038\\,196
\end{align}$$
Find $\sum_{n = 0, 1, \ldots, 17} {10}^n × D_{A,B}((127 + 19n) × 7^n)$.
# --hints--
`euler230()` should return 850481152593119200.
`fibonacciWords()` should return `850481152593119200`.
```js
assert.strictEqual(euler230(), 850481152593119200);
assert.strictEqual(fibonacciWords(), 850481152593119200);
```
# --seed--
@ -41,12 +57,12 @@ assert.strictEqual(euler230(), 850481152593119200);
## --seed-contents--
```js
function euler230() {
function fibonacciWords() {
return true;
}
euler230();
fibonacciWords();
```
# --solutions--

View File

@ -8,20 +8,20 @@ dashedName: problem-231-the-prime-factorisation-of-binomial-coefficients
# --description--
The binomial coefficient 10C3 = 120.
The binomial coefficient $\displaystyle\binom{10}{3} = 120$.
120 = 23 × 3 × 5 = 2 × 2 × 2 × 3 × 5, and 2 + 2 + 2 + 3 + 5 = 14.
$120 = 2^3 × 3 × 5 = 2 × 2 × 2 × 3 × 5$, and $2 + 2 + 2 + 3 + 5 = 14$.
So the sum of the terms in the prime factorisation of 10C3 is 14.
So the sum of the terms in the prime factorisation of $\displaystyle\binom{10}{3}$ is $14$.
Find the sum of the terms in the prime factorisation of 20000000C15000000.
Find the sum of the terms in the prime factorisation of $\binom{20\\,000\\,000}{15\\,000\\,000}$.
# --hints--
`euler231()` should return 7526965179680.
`primeFactorisation()` should return `7526965179680`.
```js
assert.strictEqual(euler231(), 7526965179680);
assert.strictEqual(primeFactorisation(), 7526965179680);
```
# --seed--
@ -29,12 +29,12 @@ assert.strictEqual(euler231(), 7526965179680);
## --seed-contents--
```js
function euler231() {
function primeFactorisation() {
return true;
}
euler231();
primeFactorisation();
```
# --solutions--

View File

@ -8,9 +8,15 @@ dashedName: problem-232-the-race
# --description--
Two players share an unbiased coin and take it in turns to play "The Race". On Player 1's turn, he tosses the coin once: if it comes up Heads, he scores one point; if it comes up Tails, he scores nothing. On Player 2's turn, she chooses a positive integer T and tosses the coin T times: if it comes up all Heads, she scores 2T-1 points; otherwise, she scores nothing. Player 1 goes first. The winner is the first to 100 or more points.
Two players share an unbiased coin and take it in turns to play "The Race".
On each turn Player 2 selects the number, T, of coin tosses that maximises the probability of her winning.
On Player 1's turn, he tosses the coin once: if it comes up Heads, he scores one point; if it comes up Tails, he scores nothing.
On Player 2's turn, she chooses a positive integer $T$ and tosses the coin $T$ times: if it comes up all Heads, she scores $2^{T - 1}$ points; otherwise, she scores nothing.
Player 1 goes first. The winner is the first to 100 or more points.
On each turn Player 2 selects the number, $T$, of coin tosses that maximises the probability of her winning.
What is the probability that Player 2 wins?
@ -18,10 +24,10 @@ Give your answer rounded to eight decimal places in the form 0.abcdefgh .
# --hints--
`euler232()` should return 0.83648556.
`theRace()` should return `0.83648556`.
```js
assert.strictEqual(euler232(), 0.83648556);
assert.strictEqual(theRace(), 0.83648556);
```
# --seed--
@ -29,12 +35,12 @@ assert.strictEqual(euler232(), 0.83648556);
## --seed-contents--
```js
function euler232() {
function theRace() {
return true;
}
euler232();
theRace();
```
# --solutions--

View File

@ -8,18 +8,18 @@ dashedName: problem-233-lattice-points-on-a-circle
# --description--
Let f(N) be the number of points with integer coordinates that are on a circle passing through (0,0), (N,0),(0,N), and (N,N).
Let $f(N)$ be the number of points with integer coordinates that are on a circle passing through $(0,0)$, $(N,0)$,$(0,N)$, and $(N,N)$.
It can be shown that f(10000) = 36.
It can be shown that $f(10000) = 36$.
What is the sum of all positive integers N ≤ 1011 such that f(N) = 420 ?
What is the sum of all positive integers $N ≤ {10}^{11}$ such that $f(N) = 420$?
# --hints--
`euler233()` should return 271204031455541300.
`latticePointsOnACircle()` should return `271204031455541300`.
```js
assert.strictEqual(euler233(), 271204031455541300);
assert.strictEqual(latticePointsOnACircle(), 271204031455541300);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler233(), 271204031455541300);
## --seed-contents--
```js
function euler233() {
function latticePointsOnACircle() {
return true;
}
euler233();
latticePointsOnACircle();
```
# --solutions--

View File

@ -8,22 +8,22 @@ dashedName: problem-234-semidivisible-numbers
# --description--
For an integer n ≥ 4, we define the lower prime square root of n, denoted by lps(n), as the largest prime ≤ √n and the upper prime square root of n, ups(n), as the smallest prime ≥ √n.
For an integer $n ≥ 4$, we define the lower prime square root of $n$, denoted by $lps(n)$, as the $\text{largest prime}\sqrt{n}$ and the upper prime square root of $n$, $ups(n)$, as the $\text{smallest prime}\sqrt{n}$.
So, for example, lps(4) = 2 = ups(4), lps(1000) = 31, ups(1000) = 37.
So, for example, $lps(4) = 2 = ups(4)$, $lps(1000) = 31$, $ups(1000) = 37$.
Let us call an integer n ≥ 4 semidivisible, if one of lps(n) and ups(n) divides n, but not both.
Let us call an integer $n ≥ 4$ semidivisible, if one of $lps(n)$ and $ups(n)$ divides $n$, but not both.
The sum of the semidivisible numbers not exceeding 15 is 30, the numbers are 8, 10 and 12. 15 is not semidivisible because it is a multiple of both lps(15) = 3 and ups(15) = 5. As a further example, the sum of the 92 semidivisible numbers up to 1000 is 34825.
The sum of the semidivisible numbers not exceeding 15 is 30, the numbers are 8, 10 and 12. 15 is not semidivisible because it is a multiple of both $lps(15) = 3$ and $ups(15) = 5$. As a further example, the sum of the 92 semidivisible numbers up to 1000 is 34825.
What is the sum of all semidivisible numbers not exceeding 999966663333?
# --hints--
`euler234()` should return 1259187438574927000.
`semidivisibleNumbers()` should return `1259187438574927000`.
```js
assert.strictEqual(euler234(), 1259187438574927000);
assert.strictEqual(semidivisibleNumbers(), 1259187438574927000);
```
# --seed--
@ -31,12 +31,12 @@ assert.strictEqual(euler234(), 1259187438574927000);
## --seed-contents--
```js
function euler234() {
function semidivisibleNumbers() {
return true;
}
euler234();
semidivisibleNumbers();
```
# --solutions--

View File

@ -8,20 +8,20 @@ dashedName: problem-235-an-arithmetic-geometric-sequence
# --description--
Given is the arithmetic-geometric sequence u(k) = (900-3k)rk-1.
Given is the arithmetic-geometric sequence $u(k) = (900 - 3k)r^{k - 1}$.
Let s(n) = Σk=1...nu(k).
Let $s(n) = \sum_{k=1 \ldots n} u(k)$.
Find the value of r for which s(5000) = -600,000,000,000.
Find the value of $r$ for which $s(5000) = -600\\,000\\,000\\,000$.
Give your answer rounded to 12 places behind the decimal point.
# --hints--
`euler235()` should return 1.002322108633.
`arithmeticGeometricSequence()` should return `1.002322108633`.
```js
assert.strictEqual(euler235(), 1.002322108633);
assert.strictEqual(arithmeticGeometricSequence(), 1.002322108633);
```
# --seed--
@ -29,12 +29,12 @@ assert.strictEqual(euler235(), 1.002322108633);
## --seed-contents--
```js
function euler235() {
function arithmeticGeometricSequence() {
return true;
}
euler235();
arithmeticGeometricSequence();
```
# --solutions--

View File

@ -10,22 +10,39 @@ dashedName: problem-236-luxury-hampers
Suppliers 'A' and 'B' provided the following numbers of products for the luxury hamper market:
Product'A''B'Beluga Caviar5248640Christmas Cake13121888Gammon Joint26243776Vintage Port57603776Champagne Truffles39365664
| Product | 'A' | 'B' |
|--------------------|------|------|
| Beluga Caviar | 5248 | 640 |
| Christmas Cake | 1312 | 1888 |
| Gammon Joint | 2624 | 3776 |
| Vintage Port | 5760 | 3776 |
| Champagne Truffles | 3936 | 5664 |
Although the suppliers try very hard to ship their goods in perfect condition, there is inevitably some spoilage - i.e. products gone bad.
The suppliers compare their performance using two types of statistic:The five per-product spoilage rates for each supplier are equal to the number of products gone bad divided by the number of products supplied, for each of the five products in turn. The overall spoilage rate for each supplier is equal to the total number of products gone bad divided by the total number of products provided by that supplier.To their surprise, the suppliers found that each of the five per-product spoilage rates was worse (higher) for 'B' than for 'A' by the same factor (ratio of spoilage rates), m>1; and yet, paradoxically, the overall spoilage rate was worse for 'A' than for 'B', also by a factor of m.
The suppliers compare their performance using two types of statistic:
There are thirty-five m>1 for which this surprising result could have occurred, the smallest of which is 1476/1475.
- The five per-product spoilage rates for each supplier are equal to the number of products gone bad divided by the number of products supplied, for each of the five products in turn.
- The overall spoilage rate for each supplier is equal to the total number of products gone bad divided by the total number of products provided by that supplier.
What's the largest possible value of m? Give your answer as a fraction reduced to its lowest terms, in the form u/v.
To their surprise, the suppliers found that each of the five per-product spoilage rates was worse (higher) for 'B' than for 'A' by the same factor (ratio of spoilage rates), $m > 1$; and yet, paradoxically, the overall spoilage rate was worse for 'A' than for 'B', also by a factor of $m$.
There are thirty-five $m > 1$ for which this surprising result could have occurred, the smallest of which is $\frac{1476}{1475}$.
What's the largest possible value of $m$? Give your answer as a string with fraction reduced to its lowest terms, in the form `u/v`.
# --hints--
`euler236()` should return 123 / 59.
`luxuryHampers()` should return a string.
```js
assert.strictEqual(euler236(), 123 / 59);
assert(typeof luxuryHampers() === 'string');
```
`luxuryHampers()` should return the string `123/59`.
```js
assert.strictEqual(luxuryHampers(), '123/59');
```
# --seed--
@ -33,12 +50,12 @@ assert.strictEqual(euler236(), 123 / 59);
## --seed-contents--
```js
function euler236() {
function luxuryHampers() {
return true;
}
euler236();
luxuryHampers();
```
# --solutions--

View File

@ -8,26 +8,25 @@ dashedName: problem-237-tours-on-a-4-x-n-playing-board
# --description--
Let T(n) be the number of tours over a 4 × n playing board such that:
Let $T(n)$ be the number of tours over a 4 × $n$ playing board such that:
The tour starts in the top left corner.
The tour consists of moves that are up, down, left, or right one square.
The tour visits each square exactly once.
The tour ends in the bottom left corner.
- The tour starts in the top left corner.
- The tour consists of moves that are up, down, left, or right one square.
- The tour visits each square exactly once.
- The tour ends in the bottom left corner.
The diagram shows one tour over a 4 × 10 board:
T(10) is 2329. What is T(1012) modulo 108?
<img class="img-responsive center-block" alt="one tour over 4 x 10 board" src="https://cdn.freecodecamp.org/curriculum/project-euler/tours-on-a-4-x-n-playing-board.gif" style="background-color: white; padding: 10px;">
$T(10)$ is 2329. What is $T({10}^{12})$ modulo ${10}^8$?
# --hints--
`euler237()` should return 15836928.
`toursOnPlayingBoard()` should return `15836928`.
```js
assert.strictEqual(euler237(), 15836928);
assert.strictEqual(toursOnPlayingBoard(), 15836928);
```
# --seed--
@ -35,12 +34,12 @@ assert.strictEqual(euler237(), 15836928);
## --seed-contents--
```js
function euler237() {
function toursOnPlayingBoard() {
return true;
}
euler237();
toursOnPlayingBoard();
```
# --solutions--

View File

@ -10,32 +10,35 @@ dashedName: problem-238-infinite-string-tour
Create a sequence of numbers using the "Blum Blum Shub" pseudo-random number generator:
s0 = 14025256 sn+1 = sn2 mod 20300713
$$
s_0 = 14025256 \\\\
s_{n + 1} = {s_n}^2 \\; mod \\; 20\\,300\\,713
$$
Concatenate these numbers s0s1s2… to create a string w of infinite length. Then, w = 14025256741014958470038053646
Concatenate these numbers $s_0s_1s_2\ldots$ to create a string $w$ of infinite length. Then, $w = 14025256741014958470038053646\ldots$
For a positive integer k, if no substring of w exists with a sum of digits equal to k, p(k) is defined to be zero. If at least one substring of w exists with a sum of digits equal to k, we define p(k) = z, where z is the starting position of the earliest such substring.
For a positive integer $k$, if no substring of $w$ exists with a sum of digits equal to $k$, $p(k)$ is defined to be zero. If at least one substring of $w$ exists with a sum of digits equal to $k$, we define $p(k) = z$, where $z$ is the starting position of the earliest such substring.
For instance:
The substrings 1, 14, 1402, … with respective sums of digits equal to 1, 5, 7, … start at position 1, hence p(1) = p(5) = p(7) = = 1.
The substrings 1, 14, 1402, … with respective sums of digits equal to 1, 5, 7, … start at position 1, hence $p(1) = p(5) = p(7) = \ldots = 1$.
The substrings 4, 402, 4025, … with respective sums of digits equal to 4, 6, 11, … start at position 2, hence p(4) = p(6) = p(11) = = 2.
The substrings 4, 402, 4025, … with respective sums of digits equal to 4, 6, 11, … start at position 2, hence $p(4) = p(6) = p(11) = \ldots = 2$.
The substrings 02, 0252, … with respective sums of digits equal to 2, 9, … start at position 3, hence p(2) = p(9) = = 3.
The substrings 02, 0252, … with respective sums of digits equal to 2, 9, … start at position 3, hence $p(2) = p(9) = \ldots = 3$.
Note that substring 025 starting at position 3, has a sum of digits equal to 7, but there was an earlier substring (starting at position 1) with a sum of digits equal to 7, so p(7) = 1, not 3.
Note that substring 025 starting at position 3, has a sum of digits equal to 7, but there was an earlier substring (starting at position 1) with a sum of digits equal to 7, so $p(7) = 1$, not 3.
We can verify that, for 0 &lt; k ≤ 103, ∑ p(k) = 4742.
We can verify that, for $0 &lt; k ≤ {10}^3$, $\sum p(k) = 4742$.
Find p(k), for 0 &lt; k ≤ 2·1015.
Find $\sum p(k)$, for $0 &lt; k ≤ 2 \times {10}^{15}$.
# --hints--
`euler238()` should return 9922545104535660.
`infiniteStringTour()` should return `9922545104535660`.
```js
assert.strictEqual(euler238(), 9922545104535660);
assert.strictEqual(infiniteStringTour(), 9922545104535660);
```
# --seed--
@ -43,12 +46,12 @@ assert.strictEqual(euler238(), 9922545104535660);
## --seed-contents--
```js
function euler238() {
function infiniteStringTour() {
return true;
}
euler238();
infiniteStringTour();
```
# --solutions--

View File

@ -16,10 +16,10 @@ Give your answer rounded to 12 places behind the decimal point in the form 0.abc
# --hints--
`euler239()` should return 0.001887854841.
`twentyTwoFoolishPrimes()` should return `0.001887854841`.
```js
assert.strictEqual(euler239(), 0.001887854841);
assert.strictEqual(twentyTwoFoolishPrimes(), 0.001887854841);
```
# --seed--
@ -27,12 +27,12 @@ assert.strictEqual(euler239(), 0.001887854841);
## --seed-contents--
```js
function euler239() {
function twentyTwoFoolishPrimes() {
return true;
}
euler239();
twentyTwoFoolishPrimes();
```
# --solutions--

View File

@ -10,22 +10,21 @@ dashedName: problem-240-top-dice
There are 1111 ways in which five 6-sided dice (sides numbered 1 to 6) can be rolled so that the top three sum to 15. Some examples are:
D1,D2,D3,D4,D5 = 4,3,6,3,5
D1,D2,D3,D4,D5 = 4,3,3,5,6
D1,D2,D3,D4,D5 = 3,3,3,6,6
D1,D2,D3,D4,D5 = 6,6,3,3,3
$$\begin{align}
& D_1,D_2,D_3,D_4,D_5 = 4,3,6,3,5 \\\\
& D_1,D_2,D_3,D_4,D_5 = 4,3,3,5,6 \\\\
& D_1,D_2,D_3,D_4,D_5 = 3,3,3,6,6 \\\\
& D_1,D_2,D_3,D_4,D_5 = 6,6,3,3,3
\end{align}$$
In how many ways can twenty 12-sided dice (sides numbered 1 to 12) be rolled so that the top ten sum to 70?
# --hints--
`euler240()` should return 7448717393364182000.
`topDice()` should return `7448717393364182000`.
```js
assert.strictEqual(euler240(), 7448717393364182000);
assert.strictEqual(topDice(), 7448717393364182000);
```
# --seed--
@ -33,12 +32,12 @@ assert.strictEqual(euler240(), 7448717393364182000);
## --seed-contents--
```js
function euler240() {
function topDice() {
return true;
}
euler240();
topDice();
```
# --solutions--