Python – Find the maximum number of triangles with given points on three lines
Given three parallel straight lines l1, l2 and l3 lying in the same plane. Total numbers of m, n and k points lie on the line l1, l2, l3 respectively. This article aims to find the maximum number of triangles formed with vertices at these points.
Input : m = 14, n = 34, k = 114
Output : 448708.0
Input : m = 95, n = 77, k = 94
Output : 2755951.0
- Total number of triangle =
- Number of triangles that is not valid triangle from l1 plane =
- Number of triangles that is not valid triangle from l2 plane =
- Number of triangles that is not valid triangle from l3 plane =
- so number of valid Triangle =
Below is the Python code implementation of the approach.
Number of triangles : 11839.0