2018-09-30 23:01:58 +01:00
---
id: 5900f3d21000cf542c50fee5
challengeType: 5
title: 'Problem 102: Triangle containment'
2019-08-05 09:17:33 -07:00
forumTopicId: 301726
2018-09-30 23:01:58 +01:00
---
## Description
<section id='description'>
Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.
Consider the following two triangles:
A(-340,495), B(-153,-910), C(835,-947)
X(-175,41), Y(-421,-714), Z(574,-645)
It can be verified that triangle ABC contains the origin, whereas triangle XYZ does not.
2020-02-08 13:29:10 -05: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 23:01:58 +01:00
NOTE: The first two examples in the file represent the triangles in the example given above.
</section>
## Instructions
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
2018-10-04 14:37:37 +01:00
tests:
- text: <code>euler102()</code> should return 228.
2019-07-25 08:44:15 -07:00
testString: assert.strictEqual(euler102(), 228);
2018-09-30 23:01:58 +01:00
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function euler102() {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return true;
}
euler102();
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
2019-07-18 08:24:12 -07:00
2018-09-30 23:01:58 +01:00
</section>