We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #102: Triangle containment

Project Euler #102: Triangle containment

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 102 from projecteuler.net

Three distinct points are plotted at random on a Cartesian plane, for which , such that a triangle is formed.

Consider the following two triangles:


It can be verified that triangle ABC contains the origin, whereas triangle XYZ does not.

You are given co-ordinates of N "random" triangles, find the number of triangles for which the interior contains the origin.

Input Format

First line contains an integer i.e. number of triangles, followed by lines each having 6 space separated integers representing a triangle.

Constraints


Output Format

Print 1 line, the number of triangles that contain origin.

Sample Input

2
-1 -2 1 -2 1 3
-2 -1 -2 1 -1 2

Sample Output

1

Author

bayleef

Difficulty

Easy

Max Score

100

Submitted By

1906

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy