2018-09-30 22:01:58 +00:00
---
id: 5900f4511000cf542c50ff63
title: 'Problem 228: Minkowski Sums'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301871
2021-01-13 02:31:00 +00:00
dashedName: problem-228-minkowski-sums
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2019-07-18 15:32:12 +00:00
2021-07-15 12:26:34 +00:00
Let $S_n$ be the regular $n$-sided polygon – or shape – whose vertices $v_k (k = 1, 2, \ldots, n)$ have coordinates:
2020-11-27 18:02:05 +00:00
2021-07-15 12:26:34 +00:00
$$\begin{align}
& x_k = cos(\frac{2k - 1}{n} × 180°) \\\\
& y_k = sin(\frac{2k - 1}{n} × 180°)
\end{align}$$
2018-09-30 22:01:58 +00:00
2021-07-15 12:26:34 +00:00
Each $S_n$ is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior.
2018-09-30 22:01:58 +00:00
2021-07-15 12:26:34 +00:00
The Minkowski sum, $S + T$, of two shapes $S$ and $T$ is the result of adding every point in $S$ to every point in $T$, where point addition is performed coordinate-wise: $(u, v) + (x, y) = (u + x, v + y)$.
2019-07-18 15:32:12 +00:00
2021-07-15 12:26:34 +00:00
For example, the sum of $S_3$ and $S_4$ is the six-sided shape shown in pink below:
2018-09-30 22:01:58 +00:00
2021-07-15 12:26:34 +00:00
< img class = "img-responsive center-block" alt = "image showing S_3, S_4 and S_3 + S_4" src = "https://cdn.freecodecamp.org/curriculum/project-euler/minkowski-sums.png" style = "background-color: white; padding: 10px;" >
2018-09-30 22:01:58 +00:00
2021-07-15 12:26:34 +00:00
How many sides does $S_{1864} + S_{1865} + \ldots + S_{1909}$ have?
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2021-07-15 12:26:34 +00:00
`minkowskiSums()` should return `86226` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-15 12:26:34 +00:00
assert.strictEqual(minkowskiSums(), 86226);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
2021-07-15 12:26:34 +00:00
function minkowskiSums() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-15 12:26:34 +00:00
minkowskiSums();
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```