freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-102-triangle-contai...

51 lines
1.1 KiB
Markdown
Raw Normal View History

---
id: 5900f3d21000cf542c50fee5
title: 'Problem 102: Triangle containment'
challengeType: 5
forumTopicId: 301726
dashedName: problem-102-triangle-containment
---
# --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.
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.
NOTE: The first two examples in the file represent the triangles in the example given above.
# --hints--
`euler102()` should return 228.
```js
assert.strictEqual(euler102(), 228);
```
# --seed--
## --seed-contents--
```js
function euler102() {
return true;
}
euler102();
```
# --solutions--
```js
// solution required
```