2018-09-30 23:01:58 +01:00
---
id: 5900f4f41000cf542c510007
title: 'Problem 392: Enmeshed unit circle'
2020-11-27 19:02:05 +01:00
challengeType: 5
2019-08-05 09:17:33 -07:00
forumTopicId: 302057
2021-01-13 03:31:00 +01:00
dashedName: problem-392-enmeshed-unit-circle
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
A rectilinear grid is an orthogonal grid where the spacing between the gridlines does not have to be equidistant.
2020-11-27 19:02:05 +01:00
An example of such grid is logarithmic graph paper.
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
Consider rectilinear grids in the Cartesian coordinate system with the following properties:
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
- The gridlines are parallel to the axes of the Cartesian coordinate system.
- There are $N + 2$ vertical and $N + 2$ horizontal gridlines. Hence there are $(N + 1) \times (N + 1)$ rectangular cells.
- The equations of the two outer vertical gridlines are $x = -1$ and $x = 1$.
- The equations of the two outer horizontal gridlines are $y = -1$ and $y = 1$.
- The grid cells are colored red if they overlap with the unit circle, black otherwise.
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
For this problem we would like you to find the positions of the remaining $N$ inner horizontal and $N$ inner vertical gridlines so that the area occupied by the red cells is minimized.
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
E.g. here is a picture of the solution for $N = 10$:
< img class = "img-responsive center-block" alt = "solution for N = 10" src = "https://cdn.freecodecamp.org/curriculum/project-euler/enmeshed-unit-circle.png" style = "background-color: white; padding: 10px;" >
The area occupied by the red cells for $N = 10$ rounded to 10 digits behind the decimal point is 3.3469640797.
Find the positions for $N = 400$. Give as your answer the area occupied by the red cells rounded to 10 digits behind the decimal point.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
`enmeshedUnitCircle()` should return `3.1486734435` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
2021-07-30 16:59:29 +02:00
assert.strictEqual(enmeshedUnitCircle(), 3.1486734435);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```js
2021-07-30 16:59:29 +02:00
function enmeshedUnitCircle() {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return true;
}
2021-07-30 16:59:29 +02:00
enmeshedUnitCircle();
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
// solution required
```