fix: clean-up Project Euler 421-440 (#43047)

This commit is contained in:
gikf
2021-07-29 20:14:09 +02:00
committed by GitHub
parent 7bd08ae2ee
commit a9c11f7fe2
20 changed files with 306 additions and 189 deletions

View File

@ -8,24 +8,36 @@ dashedName: problem-440-gcd-and-tiling
# --description--
We want to tile a board of length n and height 1 completely, with either 1 × 2 blocks or 1 × 1 blocks with a single decimal digit on top:
We want to tile a board of length $n$ and height 1 completely, with either 1 × 2 blocks or 1 × 1 blocks with a single decimal digit on top:
For example, here are some of the ways to tile a board of length n = 8:
<img class="img-responsive center-block" alt="ten blocks 1x1 with single decimal digit on top, and 1x2 block" src="https://cdn.freecodecamp.org/curriculum/project-euler/gcd-and-tiling-1.png" style="background-color: white; padding: 10px;">
Let T(n) be the number of ways to tile a board of length n as described above.
For example, here are some of the ways to tile a board of length $n = 8$:
For example, T(1) = 10 and T(2) = 101.
<img class="img-responsive center-block" alt="examples of ways to tile a board of length n = 8" src="https://cdn.freecodecamp.org/curriculum/project-euler/gcd-and-tiling-2.png" style="background-color: white; padding: 10px;">
Let S(L) be the triple sum ∑a,b,c gcd(T(ca), T(cb)) for 1 ≤ a, b, c ≤ L. For example: S(2) = 10444 S(3) = 1292115238446807016106539989 S(4) mod 987 898 789 = 670616280.
Let $T(n)$ be the number of ways to tile a board of length $n$ as described above.
Find S(2000) mod 987 898 789.
For example, $T(1) = 10$ and $T(2) = 101$.
Let $S(L)$ be the triple sum $\sum_{a, b, c} gcd(T(c^a), T(c^b))$ for $1 ≤ a, b, c ≤ L$.
For example:
$$\begin{align}
& S(2) = 10\\,444 \\\\
& S(3) = 1\\,292\\,115\\,238\\,446\\,807\\,016\\,106\\,539\\,989 \\\\
& S(4)\bmod 987\\,898\\,789 = 670\\,616\\,280.
\end{align}$$
Find $S(2000)\bmod 987\\,898\\,789$.
# --hints--
`euler440()` should return 970746056.
`gcdAndTiling()` should return `970746056`.
```js
assert.strictEqual(euler440(), 970746056);
assert.strictEqual(gcdAndTiling(), 970746056);
```
# --seed--
@ -33,12 +45,12 @@ assert.strictEqual(euler440(), 970746056);
## --seed-contents--
```js
function euler440() {
function gcdAndTiling() {
return true;
}
euler440();
gcdAndTiling();
```
# --solutions--