Citadel OA | Do They Belong? | Citadel Online Assessment Question
A triangle is formed by the three points a(x1, y1), b(x2, y2) and c(x3, y3) is a non-degenerate triangle if the following rules are respected (`|ab| is the length of the line between points a and b):
- |ab| + |bc| > |ac|
- |bc| + |ac| > |ab|
- |ab| + |ac| > |bc|
A point belongs to a triangle if it lies somewhere on or inside the triangle. Given two points p = (xp, yp) and q = (xq, yq), return the correct scenario number:
- 0. If the triangle abc does not form a valid non-degenerati triangle.
-
- If point p belongs to the triangle but point q does not.
-
- If point q belongs to the triangle but point p does not.
-
- If both points p and q belong to the triangle.
-
- If neither point p nor point q belong to the triangle.
Relevant Citadel OA Problems:
x1 = 2 y1 = 2 x2 = 7 y2 = 2 x3 = 5 y3 = 4 xp = 4 yp = 3 xq = 7 yq = 4
7
The point p(5, 4) belongs to the triangle and the point q(7, 4) does not.