An Initiative by SAARTHI IAS
Maarg Manthan · Topic 25.2

Counting the Number of Straight Lines, Rectangles or Other Shapes in a Figure

Reasoning › Non-Verbal Reasoning – Figure Counting, Embedded Figures and Completion · Topic 25.2

To count straight lines, rectangles or other shapes in a figure, use pair-selection formulas. A line containing p marked points has p(p - 1)/2 line segments. A grid with a horizontal and b vertical lines contains a(a - 1)/2 times b(b - 1)/2 rectangles, which is [m(m + 1)/2] times [n(n + 1)/2] for a grid of m rows and n columns of cells.

Share:
Counting the Number of Straight Lines, Rectangles or Other Shapes in a Figure - Reasoning - MaargX UPSC Maarg Manthan

Quick Answer

To count straight lines, rectangles or other shapes in a figure, use pair-selection formulas. A line containing p marked points has p(p – 1)/2 line segments. A grid with a horizontal and b vertical lines contains a(a – 1)/2 times b(b – 1)/2 rectangles, which is [m(m + 1)/2] times [n(n + 1)/2] for a grid of m rows and n columns of cells.

At a Glance

  • Segments on a line with p points p(p – 1)/2
  • Rectangles in an m by n grid [m(m + 1)/2] x [n(n + 1)/2]
  • Rectangles from a horizontal and b vertical lines a(a – 1)/2 x b(b – 1)/2
  • Chessboard 8 by 8 1296 rectangles, 204 squares
  • Parallelograms Same formula with two sets of parallel lines
  • Key idea Choose two lines from each direction

Where Does It Fit?

This topic follows Counting the Number of Triangles in a Given Complex Figure, which counted triangles, and uses the same pair-selection idea. It leads to Counting Figures Formed by Overlapping Shapes on overlapping shapes and Counting Squares and Other Polygons Within a Complex Figure on squares and other polygons.

How Do You Count Line Segments and Straight Lines?

In short: a line segment is fixed by choosing two of the marked points on a line, so a line with p points has p(p – 1)/2 segments.

Points on a line Segments
2 1
3 3
4 6
5 10
6 15
7 21

Counting lines and segments

  • Straight lines (maximal): count each distinct straight line once, even if it contains several segments.
  • Line segments: add p(p – 1)/2 for each line with p marked points.
  • Check what the question asks: lines or line segments.

The count of segments in the triangular figure of Counting the Number of Triangles in a Given Complex Figure follows the same rule: the base with k + 2 points has (k + 2)(k + 1)/2 segments, and each of the k + 2 apex lines is one segment.

How Do You Count Rectangles in a Grid?

In short: a rectangle is fixed by choosing two horizontal lines and two vertical lines, so the count is the product of the two pair counts.

Rectangle formulas

  • With a horizontal and b vertical lines: a(a – 1)/2 x b(b – 1)/2 rectangles.
  • For m rows and n columns of cells: a = m + 1, b = n + 1, so rectangles = [m(m + 1)/2] x [n(n + 1)/2].
  • Squares in an n by n grid: n(n + 1)(2n + 1)/6.
  • Rectangles that are not squares = total rectangles minus squares.
Grid of cells Rectangles Squares
2 by 2 9 5
3 by 3 36 14
3 by 4 60 20
4 by 4 100 30
8 by 8 (chessboard) 1296 204

The same method counts parallelograms when two sets of parallel lines cross: choose two lines from each set. Squares and other polygons are treated in more depth in Counting Squares and Other Polygons Within a Complex Figure.

What Should You Watch for in Rectangle Counting Problems?

In short: check that lines are complete, that the grid is regular, and that extra lines do not break the formula.

  • Missing lines: if a line does not run across the whole figure, the formula does not apply directly; count by region.
  • Diagonals: diagonal lines add triangles but do not add rectangles unless they form right angles.
  • Several rows of different widths: add the counts of each block and then the rectangles that span blocks.
  • Squares included: a square is a rectangle, so the total includes the squares.
  • Counting cells only: counting only the small cells misses all the larger rectangles.

For counting with overlap see Counting Figures Formed by Overlapping Shapes.

Solved Examples

Example 1

Question: How many rectangles are in a grid of 3 rows and 4 columns of cells?

  1. There are 4 horizontal and 5 vertical lines.
  2. Pairs of horizontal lines: 4 x 3 / 2 = 6. Pairs of vertical lines: 5 x 4 / 2 = 10.
  3. Rectangles = 6 x 10 = 60.

Answer: 60 rectangles.

Example 2

Question: How many rectangles are in a chessboard (8 by 8 cells)?

  1. There are 9 horizontal and 9 vertical lines.
  2. Pairs: 9 x 8 / 2 = 36 for each direction.
  3. Rectangles = 36 x 36 = 1296.

Answer: 1296 rectangles.

Example 3

Question: A straight line has 5 marked points. How many line segments does it contain?

  1. Choose 2 of the 5 points: 5 x 4 / 2.

Answer: 10 line segments.

Example 4

Question: A triangle has 3 lines drawn from the apex to the base, and no other lines. How many line segments are there in total?

  1. The two sides and the 3 inner lines are 5 apex lines, each a single segment: 5 segments.
  2. The base has 3 + 2 = 5 marked points, so it has 5 x 4 / 2 = 10 segments.
  3. Total: 5 + 10 = 15.

Answer: 15 line segments.

Example 5

Question: A figure has 4 horizontal lines and 3 vertical lines, all running across the whole figure and forming a regular grid. How many rectangles does it contain?

  1. Pairs of horizontal lines: 4 x 3 / 2 = 6.
  2. Pairs of vertical lines: 3 x 2 / 2 = 3.
  3. Rectangles = 6 x 3 = 18.

Answer: 18 rectangles.

Shortcuts and Tricks

  • Count the lines in each direction, not the cells: rectangles are fixed by line pairs.
  • For an m by n grid of cells use [m(m + 1)/2] x [n(n + 1)/2].
  • Remember that an 8 by 8 board has 1296 rectangles, 204 of which are squares.
  • For segments on a line use the pair formula with the number of marked points.
  • Separate lines from segments before you start.

Common Mistakes

  • Counting cells only and ignoring larger rectangles.
  • Using m x n instead of the pair formula.
  • Counting a square twice, once as a square and once as a rectangle.
  • Counting lines when segments were asked.
  • Using the grid formula when some lines do not span the whole figure.

Practice Questions

  1. How many rectangles are in a 2 by 3 grid of cells?
  2. How many segments are on a line with 6 marked points?
  3. How many rectangles are in a 4 by 4 grid of cells?
  4. How many horizontal lines are needed for a grid of 5 rows?
  5. How many rectangles are in a 1 by 5 grid of cells?
  6. How many rectangles are in a 5 by 5 grid of cells?

Answers: 1) 18; 2) 15; 3) 100; 4) 6; 5) 15; 6) 225.

Why Is This Topic Important?

  • Formula over counting Two pair counts replace minutes of listing.
  • Exam use Grid and chessboard questions are standard in SSC and railway papers.
  • Generalisation The same idea counts parallelograms and diagonals.
  • Link It prepares for Counting Squares and Other Polygons Within a Complex Figure and Counting Figures Formed by Overlapping Shapes.

What Comes Next?

The next topic is Embedded Figures – Identifying a Given Figure Hidden Within a Complex Figure. It asks you to find a given figure hidden inside a larger complex figure.

Key Terms and Formulas

  • Line segment The part of a line between two points
  • Grid Sets of horizontal and vertical lines crossing each other
  • Pair selection Choosing two lines from a set
  • Cell The smallest rectangle of the grid
  • Marked point A point where lines meet or end
  • Chessboard An 8 by 8 grid of cells

Exam Corner

Points to Remember

  • Segments on a line: p(p – 1)/2.
  • Rectangles: choose 2 horizontal and 2 vertical lines.
  • An m by n grid has [m(m + 1)/2] x [n(n + 1)/2] rectangles.
  • Squares are included in rectangles.
  • A chessboard has 1296 rectangles.

Do Not Confuse With

  • Lines vs segments A line is counted once; segments are counted per pair of points.
  • Cells vs lines Cells are the small boxes; lines are the dividers, one more than cells.
  • Rectangles vs squares Every square is a rectangle, not the reverse.
  • Rows vs horizontal lines m rows need m + 1 horizontal lines.

Memory Hook

Choose two lines each way and multiply.

GS Relevance

Counting lines and rectangles is a regular SSC CGL, CHSL, CAPF and railway non-verbal question, and the formulas turn long counting into short arithmetic.

Frequently Asked Questions

How do you count rectangles in a grid?

Count the horizontal lines and the vertical lines. A rectangle is fixed by choosing two of each, so the number is the product of the number of pairs of horizontal lines and the number of pairs of vertical lines. For a grid with m rows and n columns this is m(m + 1)/2 times n(n + 1)/2.

How many rectangles are in a chessboard?

A chessboard has 9 horizontal and 9 vertical lines, giving 36 pairs in each direction. The number of rectangles is 36 times 36, which is 1296. Of these, 204 are squares, since the sum of squares of 1 to 8 is 204.

How many line segments are on a line with several points?

A line segment is fixed by choosing two of the marked points, so a line with p points has p times p minus 1 divided by 2 segments. For example, a line with 5 marked points has 10 segments and one with 6 points has 15.

What is the difference between counting lines and counting segments?

A straight line is counted once however many points lie on it. Segments are counted for every pair of marked points on the line. A question must say which is wanted, and the answers differ widely when lines carry several marked points.

Why do you count lines and not cells for rectangles?

A rectangle of any size is determined by its two horizontal sides and two vertical sides, which lie on four grid lines. Counting only cells misses every larger rectangle, whereas choosing line pairs counts all sizes exactly once.

PYQ Practice — Statement Analysis

1 A 3 by 4 grid of cells contains 60 rectangles.
True

6 pairs of horizontal lines times 10 pairs of vertical lines is 60.

2 A line with 5 marked points has 5 line segments.
False

It has 5 x 4 / 2 = 10 segments.

3 A chessboard has 64 rectangles.
False

It has 1296 rectangles; 64 is the number of cells.

4 Squares are included in the count of rectangles.
True

A square is a rectangle with equal sides.

Share: