Files
gikf 1af6e7aa5a fix(curriculum): clean-up Project Euler 321-340 (#42988)
* fix: clean-up Project Euler 321-340

* fix: typo

* fix: corrections from review

Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>

* fix: corrections from review

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

Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2021-07-29 11:59:06 -07:00

45 lines
1.5 KiB
Markdown

---
id: 5900f4c01000cf542c50ffd2
title: 'Problem 339: Peredur fab Efrawg'
challengeType: 5
forumTopicId: 301997
dashedName: problem-339-peredur-fab-efrawg
---
# --description--
"And he came towards a valley, through which ran a river; and the borders of the valley were wooded, and on each side of the river were level meadows. And on one side of the river he saw a flock of white sheep, and on the other a flock of black sheep. And whenever one of the white sheep bleated, one of the black sheep would cross over and become white; and when one of the black sheep bleated, one of the white sheep would cross over and become black." - Peredur the Son of Evrawc
Initially, each flock consists of $n$ sheep. Each sheep (regardless of color) is equally likely to be the next sheep to bleat. After a sheep has bleated and a sheep from the other flock has crossed over, Peredur may remove a number of white sheep in order to maximize the expected final number of black sheep. Let $E(n)$ be the expected final number of black sheep if Peredur uses an optimal strategy.
You are given that $E(5) = 6.871346$ rounded to 6 places behind the decimal point.
Find $E(10\\,000)$ and give your answer rounded to 6 places behind the decimal point.
# --hints--
`peredurFabEfrawg()` should return `19823.542204`.
```js
assert.strictEqual(peredurFabEfrawg(), 19823.542204);
```
# --seed--
## --seed-contents--
```js
function peredurFabEfrawg() {
return true;
}
peredurFabEfrawg();
```
# --solutions--
```js
// solution required
```