2018-09-30 22:01:58 +00:00
---
id: 5900f3d21000cf542c50fee5
title: 'Problem 102: Triangle containment'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301726
2021-01-13 02:31:00 +00:00
dashedName: problem-102-triangle-containment
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-09-30 22:01:58 +00:00
Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
Consider the following two triangles:
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
A(-340,495), B(-153,-910), C(835,-947)
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
X(-175,41), Y(-421,-714), Z(574,-645)
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
It can be verified that triangle ABC contains the origin, whereas triangle XYZ does not.
2020-11-27 18:02:05 +00:00
Using triangles.txt (right click and 'Save Link/Target As...'), a 27K text file containing the coordinates of one thousand "random" triangles, find the number of triangles for which the interior contains the origin.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
NOTE: The first two examples in the file represent the triangles in the example given above.
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
2020-11-27 18:02:05 +00:00
`euler102()` should return 228.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert.strictEqual(euler102(), 228);
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
function euler102() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
euler102();
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```