3
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:
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)
:
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 code-golf 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
1
Well-written challenge, but we already have it.
– xnor – 2016-06-17T09:42:57.380Well, 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. – shooqie – 2016-06-17T09:46:43.120
Your challenge won't be deleted. It's closed, which disables answering it but keeps it visible. – xnor – 2016-06-17T09:49:52.203