3
\$\begingroup\$

Challenge description

On a Cartesian plane, a triangle can be described as a set of three points, each point being one of the triangle's vertices. For instance, coordinates (2, 1), (6, 8), (-7, 3) correspond to the following triangle:

TRIANGLE #1

As you can see, it does not contain the origin of the plane, i.e. the point (0, 0), unlike the triangle (-5, 3), (2, 7), (3, -8):

TRIANGLE #2

Your job is to write a program, that given exactly six integers describing coordinates of a triangle, determines whether or not it contains the origin of the Cartesian plane. The objective is to make your code as short as possible, since this is a challenge.

Input

Six integers corresponding to three coordinates of a triangle, for example:

1 4 -9 0 3 -4 -> (1, 4), (-9, 0), (3, -4)

You can also accept a list of integers, a list of two-tuples... - whatever is most convenient or makes your code shorter.

Output

A truthy value if the triangle contains the origin (1, True), falsy value otherwise (0, False). You don't need to validate the input.

Sample inputs / outputs

(18, -36), (36, 19), (-15, 9) -> True
(-23, 31), (-27, 40), (32, 22) -> False
(-40, -34), (35, 20), (47, 27) -> False
(0, 6), (-36, -42), (12, -34) -> True
(-24, 6), (36, 6), (-14, -25) -> True

Triangle images courtesy of Wolfram Alpha

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Well-written challenge, but we already have it. \$\endgroup\$ – xnor Jun 17 '16 at 9:42
  • \$\begingroup\$ Well, that's a shame... should've searched more thoroughly for duplicates. I'm just gonna leave it like this, worst-case scenario it will get deleted by mods. \$\endgroup\$ – shooqie Jun 17 '16 at 9:46
  • \$\begingroup\$ Your challenge won't be deleted. It's closed, which disables answering it but keeps it visible. \$\endgroup\$ – xnor Jun 17 '16 at 9:49