# Project Euler #102: Triangle containment

# Project Euler #102: Triangle containment

+ 1 comment Can somebody let me know test case #1 please? thats the only case i am failing at.

+ 1 comment I don't know why everybody here makes this problem too complicated by using Interior Triangle (Convex Hull) or Barycentric Coordinate.

**Just think about highschool math**.**Hint**: Calculate the area S of ABC, OAB, OAC and OBC. If O is inside ABC, then S_ABC = S_OAB + S_OAC + S_OBC.**Trick**: To avoid numerical errors, use`abs(S_ABC - S_OAB - S_OAC - S_OBC) < 1e-9`

instead of`S_ABC == S_OAB + S_OAC + S_OBC`

+ 0 comments A bit of clarification of criteria is in order.

The origin on one of the sides of a triangle should be counted as IN, not out.

There will be no test cases where the origin itself is one of the triangle corners.

+ 0 comments The description of is contradictory to the constraints . This is what stops me from getting the last two test cases right.

+ 0 comments If (0 ,0) is in the perimeter, the problem statement does not make clear if it should be considered an interior point. Neither did the original project euler statement, but there didn't affect the outcome since there were no triangle with sides intersecting (0, 0).

But here thet distinction matters, particularly in Test #1. And the answer is

**YES, if (0, 0) is in one side of the triangle, then it is considered interior**.

Sort 25 Discussions, By:

Please Login in order to post a comment