Sub topic 11
Counting Lines, Triangles and Diagonals
This chapter assumes you can compute nCr, apply the multiplication principle, and use the complement method for "at least" counts. Geometry counting is combinations in disguise. You pick points, and the figure they form does not depend on the order of picking. The work lies in deciding which selections form a valid figure and which are degenerate, for example three collinear points that make no triangle.
The Core Idea
Treat each geometric object as a selection of points from a given set.
- A line needs 2 points, so the count is nC2.
- A triangle needs 3 non-collinear points.
- A quadrilateral needs 4 points, no three collinear, when the points are in general position.
If no three points are collinear (this is called general position), every selection of the right size gives a valid figure.
| Points (general position) | Figure | Count |
|---|---|---|
| 2 | Line segment or line | nC2 |
| 3 | Triangle | nC3 |
| 4 | Quadrilateral, each 4-set gives one convex quadrilateral | nC4 |
| 4 | Intersection points of diagonals | nC4 |
Lines from n Points
With n points in general position, the number of distinct lines is nC2, because each pair of points fixes exactly one line.
Collinear points change this. Suppose m of the n points lie on one straight line. Those m points would give mC2 pairs, but they all produce the same single line. So:
Number of lines = nC2 − mC2 + 1
With 10 points of which 4 are collinear, the count is 10C2 − 4C2 + 1 = 45 − 6 + 1 = 40.
If there are several separate collinear groups, subtract mC2 for each group and add 1 for each group.
Triangles from n Points
With n points in general position, the number of triangles is nC3.
If m points are collinear, any 3 chosen from them fail to form a triangle. Subtract those selections:
Number of triangles = nC3 − mC3
With 10 points of which 4 are collinear: 10C3 − 4C3 = 120 − 4 = 116.
With two collinear groups of sizes m and k, subtract both: nC3 − mC3 − kC3.
import math
def lines(n, collinear_groups=()):
# collinear_groups: sizes of groups of collinear points
total = math.comb(n, 2)
for m in collinear_groups:
total = total - math.comb(m, 2) + 1
return total
def triangles(n, collinear_groups=()):
total = math.comb(n, 3)
for m in collinear_groups:
total -= math.comb(m, 3)
return total
print(lines(10, (4,))) # 40
print(triangles(10, (4,))) # 116
print(triangles(12, (5, 4))) # 220 - 10 - 4 = 206The function assumes the groups are disjoint, or share at most one point, and that no triple of points is counted in two groups. That holds for two distinct lines, which meet in at most one point.
Triangles with Vertices on Two Lines
A common CAT setup places a points on one line and b points on another, with no point at the intersection. A triangle needs 3 points that are not all on the same line, so it takes 2 points from one line and 1 from the other.
Number of triangles = aC2 × bC1 + aC1 × bC2
Check with a = 5, b = 4: 10 × 4 + 5 × 6 = 40 + 30 = 70.
The complement method gives the same result: (a+b)C3 − aC3 − bC3 = 84 − 10 − 4 = 70.
import math
a, b = 5, 4
direct = math.comb(a, 2) * b + a * math.comb(b, 2)
complement = math.comb(a + b, 3) - math.comb(a, 3) - math.comb(b, 3)
print(direct, complement) # 70 70Quadrilaterals work the same way: take 2 points from each line, giving aC2 × bC2. For a = 5 and b = 4 that is 10 × 6 = 60. Taking 3 from one line and 1 from the other gives no quadrilateral.
Diagonals of a Polygon
A convex polygon with n vertices has nC2 pairs of vertices. Of these pairs, n are sides. The rest are diagonals:
Diagonals = nC2 − n = n(n − 3) / 2
A hexagon has 6 × 3 / 2 = 9 diagonals. A decagon has 10 × 7 / 2 = 35.
A diagonal joins two non-adjacent vertices. Each vertex connects to n − 3 others, because it skips itself and its two neighbors. Multiplying by n counts each diagonal twice, so divide by 2.
Working Backward from the Diagonal Count
A question may say a polygon has 54 diagonals and ask for the number of sides. Solve n(n − 3) / 2 = 54, so n² − 3n − 108 = 0. This factors as (n − 12)(n + 9) = 0, giving n = 12. Discard the negative root.
Triangles Formed in a Polygon
For a convex n-gon, choosing any 3 vertices gives a triangle, so there are nC3 triangles with vertices at the polygon's vertices.
Two refinements often appear:
- Triangles with exactly 2 sides shared with the polygon: choose a vertex as the middle one, giving n triangles.
- Triangles with exactly 1 side shared with the polygon: n × (n − 4) triangles. Pick a side (n ways), then a third vertex that is not adjacent to either end (n − 4 choices).
- Triangles with no side shared with the polygon: the rest.
Check for n = 8: total 8C3 = 56. Two shared sides: 8. One shared side: 8 × 4 = 32. None shared: 56 − 8 − 32 = 16. The standard formula for none shared is n(n − 4)(n − 5) / 6, which gives 8 × 4 × 3 / 6 = 16, so the two methods agree.
import math
n = 8
total = math.comb(n, 3)
two = n
one = n * (n - 4)
none = total - two - one
print(total, two, one, none) # 56 8 32 16
print(n * (n - 4) * (n - 5) // 6) # 16Intersection Points of Diagonals
Four vertices of a convex polygon determine exactly one pair of crossing diagonals, which meet at one interior point. If no three diagonals meet at a single point, the number of interior intersection points is nC4.
A convex hexagon gives 6C4 = 15 points. The condition about three diagonals meeting is important. A regular hexagon has its three long diagonals meeting at the center, so the true count is smaller. CAT questions normally state the assumption or the polygon is not regular.
Grid and Rectangle Counting
Rectangles in a grid also reduce to combinations. An m × n grid of squares has m + 1 horizontal lines and n + 1 vertical lines. A rectangle uses 2 of each:
Rectangles = (m+1)C2 × (n+1)C2
For a standard 8 × 8 chessboard, 9C2 × 9C2 = 36 × 36 = 1296. Squares are not found this way, because they need equal side lengths. They are counted with a sum of squares: 1² + 2² + … + 8² = 204. Of the 1296 rectangles, 204 are squares.
import math
m = n = 8
rectangles = math.comb(m + 1, 2) * math.comb(n + 1, 2)
squares = sum(k * k for k in range(1, 9))
print(rectangles, squares) # 1296 204Common Mistakes
- Using nC2 for lines without correcting for collinear points.
- Subtracting mC3 for collinear points but forgetting that lines need the "+1" correction.
- Counting diagonals as nC2 and not removing the n sides.
- Applying nC4 for diagonal intersections when the polygon is not convex or several diagonals are concurrent.
- Counting squares with the rectangle formula.
Worked Problem
Twelve points lie in a plane. Five are collinear, and no other three are collinear. Find the number of triangles and the number of lines.
- Triangles: 12C3 − 5C3 = 220 − 10 = 210.
- Lines: 12C2 − 5C2 + 1 = 66 − 10 + 1 = 57.
Exercise
Seven points lie on one line and five points lie on a parallel line. How many triangles can be formed with vertices among these 12 points, and how many quadrilaterals?
Show answer
Triangles: 7C2 × 5 + 7 × 5C2 = 21 × 5 + 7 × 10 = 105 + 70 = 175. Check: 12C3 − 7C3 − 5C3 = 220 − 35 − 10 = 175. Quadrilaterals take 2 points from each line: 7C2 × 5C2 = 21 × 10 = 210.
Exercise
A convex polygon has 44 diagonals. How many sides does it have, and how many triangles have all three vertices at polygon vertices but no side in common with the polygon?
Show answer
Solve n(n − 3)/2 = 44, so n² − 3n − 88 = 0, which gives (n − 11)(n + 8) = 0 and n = 11. Triangles with no shared side: n(n − 4)(n − 5)/6 = 11 × 7 × 6 / 6 = 77.