fix(curriculum): clean-up Project Euler 441-460 (#43068)

* fix: clean-up Project Euler 441-460

* 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-30 17:20:31 +02:00
committed by GitHub
parent d269909faa
commit a2b2ef3f75
20 changed files with 267 additions and 185 deletions

View File

@ -8,28 +8,38 @@ dashedName: problem-459-flipping-game
# --description--
The flipping game is a two player game played on a N by N square board.
The flipping game is a two player game played on a $N$ by $N$ square board.
Each square contains a disk with one side white and one side black.
The game starts with all disks showing their white side.
A turn consists of flipping all disks in a rectangle with the following properties: the upper right corner of the rectangle contains a white disk the rectangle width is a perfect square (1, 4, 9, 16, ...) the rectangle height is a triangular number (1, 3, 6, 10, ...)
A turn consists of flipping all disks in a rectangle with the following properties:
- the upper right corner of the rectangle contains a white disk
- the rectangle width is a perfect square (1, 4, 9, 16, ...)
- the rectangle height is a triangular number (1, 3, 6, 10, ...)
<img class="img-responsive center-block" alt="flipping all disks in a 4x3 rectangle on a 5x5 board" src="https://cdn.freecodecamp.org/curriculum/project-euler/flipping-game-1.png" style="background-color: white; padding: 10px;">
Players alternate turns. A player wins by turning the grid all black.
Let W(N) be the number of winning moves for the first player on a N by N board with all disks white, assuming perfect play. W(1) = 1, W(2) = 0, W(5) = 8 and W(102) = 31395.
Let $W(N)$ be the number of winning moves for the first player on a $N$ by $N$ board with all disks white, assuming perfect play.
For N=5, the first player's eight winning first moves are:
$W(1) = 1$, $W(2) = 0$, $W(5) = 8$ and $W({10}^2) = 31\\,395$.
Find W(106).
For $N = 5$, the first player's eight winning first moves are:
<img class="img-responsive center-block" alt="eight winning first moves for N = 5" src="https://cdn.freecodecamp.org/curriculum/project-euler/flipping-game-2.png" style="background-color: white; padding: 10px;">
Find $W({10}^6)$.
# --hints--
`euler459()` should return 3996390106631.
`flippingGame()` should return `3996390106631`.
```js
assert.strictEqual(euler459(), 3996390106631);
assert.strictEqual(flippingGame(), 3996390106631);
```
# --seed--
@ -37,12 +47,12 @@ assert.strictEqual(euler459(), 3996390106631);
## --seed-contents--
```js
function euler459() {
function flippingGame() {
return true;
}
euler459();
flippingGame();
```
# --solutions--