2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
id: 5900f4511000cf542c50ff63
|
2021-02-06 04:42:36 +00:00
|
|
|
|
title: 'Problem 228: Minkowski Sums'
|
2018-10-10 22:03:03 +00:00
|
|
|
|
challengeType: 5
|
2021-02-06 04:42:36 +00:00
|
|
|
|
forumTopicId: 301871
|
2021-01-13 02:31:00 +00:00
|
|
|
|
dashedName: problem-228-minkowski-sums
|
2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --description--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
<!-- TODO Use MathJax and re-write from projecteuler.net -->
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
Let Sn be the regular n-sided polygon – or shape – whose vertices
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
vk (k = 1,2,…,n) have coordinates:
|
|
|
|
|
|
|
|
|
|
xk = cos( 2k-1/n ×180° )
|
|
|
|
|
|
|
|
|
|
yk = sin( 2k-1/n ×180° )
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
Each Sn is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior.
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
The Minkowski sum, S+T, of two shapes S and T is the result of
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
adding every point in S to every point in T, where point addition is performed coordinate-wise:
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
(u, v) + (x, y) = (u+x, v+y).
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
For example, the sum of S3 and S4 is the six-sided shape shown in pink below:
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
|
How many sides does S1864 + S1865 + … + S1909 have?
|
2018-10-10 22:03:03 +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
|
|
|
|
`euler228()` should return 86226.
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 07:37:30 +00:00
|
|
|
|
assert.strictEqual(euler228(), 86226);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
```
|
2020-08-13 15:24:35 +00:00
|
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function euler228() {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
euler228();
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --solutions--
|
|
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|