fix: clean-up Project Euler 401-420 (#43028)

This commit is contained in:
gikf
2021-07-29 19:48:24 +02:00
committed by GitHub
parent c18554dd44
commit 7bd08ae2ee
20 changed files with 269 additions and 182 deletions

View File

@ -8,22 +8,26 @@ dashedName: problem-411-uphill-paths
# --description--
Let n be a positive integer. Suppose there are stations at the coordinates (x, y) = (2i mod n, 3i mod n) for 0 ≤ i ≤ 2n. We will consider stations with the same coordinates as the same station.
Let $n$ be a positive integer. Suppose there are stations at the coordinates $(x, y) = (2^i\bmod n, 3^i\bmod n)$ for $0 ≤ i ≤ 2n$. We will consider stations with the same coordinates as the same station.
We wish to form a path from (0, 0) to (n, n) such that the x and y coordinates never decrease. Let S(n) be the maximum number of stations such a path can pass through.
We wish to form a path from (0, 0) to ($n$, $n$) such that the $x$ and $y$ coordinates never decrease.
For example, if n = 22, there are 11 distinct stations, and a valid path can pass through at most 5 stations. Therefore, S(22) = 5. The case is illustrated below, with an example of an optimal path:
Let $S(n)$ be the maximum number of stations such a path can pass through.
It can also be verified that S(123) = 14 and S(10000) = 48.
For example, if $n = 22$, there are 11 distinct stations, and a valid path can pass through at most 5 stations. Therefore, $S(22) = 5$. The case is illustrated below, with an example of an optimal path:
Find ∑ S(k5) for 1 ≤ k ≤ 30.
<img class="img-responsive center-block" alt="valid path passing through 5 stations, for n = 22, with 11 distinct stations" src="https://cdn.freecodecamp.org/curriculum/project-euler/uphill-paths.png" style="background-color: white; padding: 10px;">
It can also be verified that $S(123) = 14$ and $S(10\\,000) = 48$.
Find $\sum S(k^5)$ for $1 ≤ k ≤ 30$.
# --hints--
`euler411()` should return 9936352.
`uphillPaths()` should return `9936352`.
```js
assert.strictEqual(euler411(), 9936352);
assert.strictEqual(uphillPaths(), 9936352);
```
# --seed--
@ -31,12 +35,12 @@ assert.strictEqual(euler411(), 9936352);
## --seed-contents--
```js
function euler411() {
function uphillPaths() {
return true;
}
euler411();
uphillPaths();
```
# --solutions--