2018-10-10 22:03:03 +00:00
---
id: 5900f51a1000cf542c51002d
2021-02-06 04:42:36 +00:00
title: 'Problem 430: Range flips'
2018-10-10 22:03:03 +00:00
challengeType: 5
2021-02-06 04:42:36 +00:00
forumTopicId: 302101
2021-01-13 02:31:00 +00:00
dashedName: problem-430-range-flips
2018-10-10 22:03:03 +00:00
---
2020-12-16 07:37:30 +00:00
# --description--
2021-02-06 04:42:36 +00:00
N disks are placed in a row, indexed 1 to N from left to right.
2020-12-16 07:37:30 +00:00
2021-02-06 04:42:36 +00:00
Each disk has a black side and white side. Initially all disks show their white side.
2020-02-17 16:40:55 +00:00
2021-02-06 04:42:36 +00:00
At each turn, two, not necessarily distinct, integers A and B between 1 and N (inclusive) are chosen uniformly at random. All disks with an index from A to B (inclusive) are flipped.
2020-02-17 16:40:55 +00:00
2021-02-06 04:42:36 +00:00
The following example shows the case N = 8. At the first turn A = 5 and B = 2, and at the second turn A = 4 and B = 6.
2020-02-17 16:40:55 +00:00
2021-02-06 04:42:36 +00:00
Let E(N, M) be the expected number of disks that show their white side after M turns. We can verify that E(3, 1) = 10/9, E(3, 2) = 5/3, E(10, 4) ≈ 5.157 and E(100, 10) ≈ 51.893.
2020-02-17 16:40:55 +00:00
2021-02-06 04:42:36 +00:00
Find E(1010, 4000). Give your answer rounded to 2 decimal places behind the decimal point.
2020-02-17 16:40:55 +00:00
2020-12-16 07:37:30 +00:00
# --hints--
2018-10-10 22:03:03 +00:00
2021-02-06 04:42:36 +00:00
`euler430()` should return 5000624921.38.
2018-10-10 22:03:03 +00:00
```js
2020-12-16 07:37:30 +00:00
assert.strictEqual(euler430(), 5000624921.38);
2018-10-10 22:03:03 +00:00
```
2021-01-13 02:31:00 +00:00
# --seed--
## --seed-contents--
```js
function euler430() {
return true;
}
euler430();
```
2020-12-16 07:37:30 +00:00
# --solutions--
2020-08-13 15:24:35 +00:00
2021-01-13 02:31:00 +00:00
```js
// solution required
```