P102
projecteuler.net

Triangle Containment

ℹ️Published on Friday, 12th August 2005, 06:00 pm; Solved by 24180;
Difficulty rating: 15%

Three distinct points are plotted at random on a Cartesian plane, for which $-1000 \le x, y \le 1000$, such that a triangle is formed.

Consider the following two triangles:

\begin{gather} A(-340,495), B(-153,-910), C(835,-947)\\ X(-175,41), Y(-421,-714), Z(574,-645) \end{gather}

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 co-ordinates 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.



Soluzione

Last modified: May 01, 2025. Website built with Franklin.jl and the lovely Julia programming language.