7.2 Grid Perimeter, Shaded Area, Sub-Shape Counting & Shortest Lattice Paths

Key Takeaways

  • An m×nm \times n grid of unit squares is bounded by m+1m+1 horizontal lines and n+1n+1 vertical lines, containing (m+12)(n+12)=m(m+1)2⋅n(n+1)2\binom{m+1}{2}\binom{n+1}{2} = \frac{m(m+1)}{2}\cdot\frac{n(n+1)}{2} total rectangles and ∑k=1min⁡(m,n)(m−k+1)(n−k+1)\sum_{k=1}^{\min(m,n)}(m-k+1)(n-k+1) total squares.

  • The number of rectangles in an m×nm \times n grid that cover a specific marked unit cell at row rr and column cc is r(m−r+1)⋅c(n−c+1)r(m - r + 1) \cdot c(n - c + 1).

  • In a triangle divided from apex AA into nn base segments and intersected by mm horizontal lines parallel to the base, the total number of triangles is m⋅n(n+1)2m \cdot \frac{n(n+1)}{2}.

  • Shaded lattice polygon areas are solved via Bounding-Box Subtraction or Pick's Theorem (Area=I+B2−1\text{Area} = I + \frac{B}{2} - 1), while polyomino perimeters obey P=4Nsquares−2Nshared edgesP = 4N_{\text{squares}} - 2N_{\text{shared edges}}.

  • Shortest paths across an m×nm \times n street grid equal (m+nm)\binom{m+n}{m}, whereas grids with missing road segments or multiple obstacles are solved via Pascal-triangle node addition (Köşe Toplama Yöntemi).

Last updated: October 2026

7.2 Grid Perimeter, Shaded Area, Sub-Shape Counting & Shortest Lattice Paths

Visual-quantitative problems on the TR-YÖS bridge geometry and combinatorics. Rather than asking you to count dozens of overlapping shapes or trace paths by hand—which invites double-counting or omission errors under time pressure—these items reward clean structural formulas for sub-shape enumeration, unit-grid area/perimeter, and lattice path routing.


The rectangle and square counts below use sides along the drawn grid lines; tilted squares require a different count.

1. Counting Rectangles, Squares, and Triangles in a Grid (Şekil Sayma)

Rectangles and Squares in an m×nm \times n Grid

Consider an m×nm \times n grid made of mm rows and nn columns of 1×11 \times 1 unit squares. Geometrically, this grid is formed by m+1m + 1 horizontal lines and n+1n + 1 vertical lines:

  1. Total Number of Rectangles (Including Squares): Every rectangle is uniquely determined by choosing any 22 of the m+1m + 1 horizontal lines (top and bottom borders) and any 22 of the n+1n + 1 vertical lines (left and right borders):
Nrectangles=(m+12)×(n+12)=m(m+1)2⋅n(n+1)2N_{\text{rectangles}} = \binom{m+1}{2} \times \binom{n+1}{2} = \frac{m(m+1)}{2} \cdot \frac{n(n+1)}{2}
  1. Total Number of Squares: A k×kk \times k square can be placed in (m−k+1)(m - k + 1) vertical positions and (n−k+1)(n - k + 1) horizontal positions. Summing over all possible side lengths k=1,2,…,min⁡(m,n)k = 1, 2, \dots, \min(m, n) gives the countdown product sum:
Nsquares=∑k=1min⁡(m,n)(m−k+1)(n−k+1)=mn+(m−1)(n−1)+(m−2)(n−2)+…N_{\text{squares}} = \sum_{k=1}^{\min(m,n)} (m - k + 1)(n - k + 1) = m n + (m-1)(n-1) + (m-2)(n-2) + \dots

In the special case of an n×nn \times n square grid, this simplifies to the sum of squares:

Nsquares (n×n)=12+22+⋯+n2=n(n+1)(2n+1)6N_{\text{squares }(n \times n)} = 1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}

To find the number of non-square rectangles, compute Nrectangles−NsquaresN_{\text{rectangles}} - N_{\text{squares}}.

  1. Rectangles and Squares Containing a Specific Marked Cell (r,c)(r, c): Suppose the unit cell at row rr (1≤r≤m1 \le r \le m from the top) and column cc (1≤c≤n1 \le c \le n from the left) contains a star or shaded mark. For a rectangle to enclose cell (r,c)(r, c):
    • Its top border must be chosen from the rr horizontal grid lines on or above row rr.
    • Its bottom border must be chosen from the m−r+1m - r + 1 horizontal grid lines on or below row rr.
    • Its left border must be chosen from the cc vertical grid lines on or to the left of column cc.
    • Its right border must be chosen from the n−c+1n - c + 1 vertical grid lines on or to the right of column cc. By the multiplication principle:
Ncontaining (r,c)=r(m−r+1)×c(n−c+1)N_{\text{containing }(r,c)} = r(m - r + 1) \times c(n - c + 1)

If a question asks for squares of side kk containing (r,c)(r, c), count how many valid k×kk \times k windows overlap row rr and column cc for each k=1,2,…,min⁡(m,n)k = 1, 2, \dots, \min(m, n) and sum the valid placements.

Counting Triangles in Cevian Fans from Vertex AA

Suppose kk interior line segments (cevians) are drawn from apex AA of △ABC\triangle ABC down to base BCBC, partitioning BCBC into n=k+1n = k + 1 elementary base segments:

  • Any choice of 22 rays out of the n+1n + 1 rays emanating from AA forms a unique triangle with apex AA: there are (n+12)=n(n+1)2\binom{n+1}{2} = \frac{n(n+1)}{2} such triangles.
  • If mm horizontal lines (including base BCBC itself) are drawn parallel to BCBC across the fan, each horizontal line acts as an independent base for those n(n+1)2\frac{n(n+1)}{2} apex-AA triangles:
Ntriangles=m×n(n+1)2N_{\text{triangles}} = m \times \frac{n(n+1)}{2}

2. Shaded Grid Area & Polyomino Perimeter (Birim Kareli Zeminde Alan ve Çevre)

Shaded Lattice Polygons: Bounding Box vs. Pick's Theorem

When a tilted triangle or polygon is drawn with vertices on the intersections (lattice points) of a unit-square grid, its side lengths are irrational square roots, so avoid using 12bh\frac{1}{2}bh with tilted bases. Instead, apply one of two exact methods:

  1. Bounding-Box Subtraction (Çerçeve Alanından Dış Üçgenleri Çıkarma): Enclose the shaded polygon inside the tightest axis-parallel rectangle of area W×HW \times H, then subtract the areas of the unshaded right triangles (12ab\frac{1}{2}ab) and corner rectangles around the outside.
  2. Pick's Theorem (Pick Teoremi): For any simple polygon whose vertices all lie on integer lattice points:
Area=I+B2−1\text{Area} = I + \frac{B}{2} - 1

where II is the number of lattice points strictly inside the polygon and BB is the number of lattice points lying on its boundary perimeter. Along a straight segment from (x1,y1)(x_1, y_1) to (x2,y2)(x_2, y_2), the number of boundary steps is gcd⁡(∣x2−x1∣,∣y2−y1∣)\gcd(\lvert x_2 - x_1 \rvert, \lvert y_2 - y_1 \rvert).

Polyomino Perimeter Formula

When NsquaresN_{\text{squares}} unit squares (each having perimeter 44) are glued together edge-to-edge, every shared internal edge eliminates two unit segments (11 from each adjacent square) from the exterior boundary:

Perimeter=4Nsquares−2Nshared internal edges\text{Perimeter} = 4 N_{\text{squares}} - 2 N_{\text{shared internal edges}}

The shared-edge formula counts every boundary, including hole boundaries. To obtain only the outer perimeter of a shape with holes, subtract the boundary lengths of those holes. Use direct edge counting when a bounding-box shortcut is not justified.


3. Shortest Lattice Paths (En Kısa Yol / Izgara Yolları)

A traveler moving along an m×nm \times n rectangular street grid from bottom-left corner A(0,0)A(0,0) to top-right corner B(m,n)B(m,n) takes a shortest path if and only if every step moves strictly East (EE, +x+x) or North (NN, +y+y).

  1. Unrestricted Grid (mm steps East, nn steps North): Every shortest path is a permutation of mm identical EE's and nn identical NN's of total length m+nm + n:
Paths(A→B)=(m+nm)=(m+n)!m! n!\text{Paths}(A \to B) = \binom{m+n}{m} = \frac{(m+n)!}{m!\,n!}
  1. Mandatory Checkpoint C(x1,y1)C(x_1, y_1): By the multiplication rule, multiply the paths from AA to CC by the paths from CC to BB:
Paths(A→C→B)=(x1+y1x1)×((m−x1)+(n−y1)m−x1)\text{Paths}(A \to C \to B) = \binom{x_1 + y_1}{x_1} \times \binom{(m - x_1) + (n - y_1)}{m - x_1}
  1. Blocked Intersection or Missing Road Segment — Pascal Node-Labeling (Köşe Toplama Yöntemi):
    • If a single intersection XX is blocked, subtract the forbidden paths: Paths(A→B)−Paths(A→X→B)\text{Paths}(A \to B) - \text{Paths}(A \to X \to B).
    • If multiple intersections/edges are missing or the grid is L-shaped/irregular, label the starting corner AA with 11, propagate 11's along the outer bottom and left boundary edges (up to any break), and fill every interior node recursively using:
P(x,y)=P(x−1,y)+P(x,y−1)P(x, y) = P(x - 1, y) + P(x, y - 1)
 setting $P = 0$ at any blocked intersection and omitting the term from any missing road segment.
Grid / Combinatorial TaskFormula / RuleParameter Definitions
Total Rectangles in m×nm \times n Grid(m+12)(n+12)=m(m+1)n(n+1)4\binom{m+1}{2}\binom{n+1}{2} = \frac{m(m+1)n(n+1)}{4}m=m = rows, n=n = columns of unit squares
Total Squares in m×nm \times n Grid∑k=1min⁡(m,n)(m−k+1)(n−k+1)\sum_{k=1}^{\min(m,n)}(m-k+1)(n-k+1)Reduces to n(n+1)(2n+1)6\frac{n(n+1)(2n+1)}{6} when m=nm = n
Rectangles Covering Cell (r,c)(r, c)r(m−r+1)⋅c(n−c+1)r(m - r + 1) \cdot c(n - c + 1)(r,c)=(r, c) = 1-indexed row and column of the cell
Cevian Fan Trianglesm⋅n(n+1)2m \cdot \frac{n(n+1)}{2}n=n = base intervals on BCBC; m=m = horizontal lines
Pick's Theorem & Polyomino PPA=I+B2−1A = I + \frac{B}{2} - 1; P=4Nsq−2NsharedP = 4N_{\text{sq}} - 2N_{\text{shared}}I=I = interior points, B=B = boundary points
Shortest Lattice Paths(m+nm)=(m+n)!m! n!\binom{m+n}{m} = \frac{(m+n)!}{m!\,n!}m=m = East steps, n=n = North steps

Worked Examples

Worked Example 7.2.1: Sub-Shape Counting & Marked Cell in a 4×54 \times 5 Grid

Problem: A 4×54 \times 5 rectangular grid consists of 44 rows and 55 columns of unit squares, with a star (⋆\star) placed inside the unit square at row r=2r = 2 (from the top) and column c=3c = 3 (from the left). Determine: (a) the total number of rectangles in the grid, (b) the total number of squares in the grid, and (c) how many rectangles contain the starred cell (2,3)(2, 3).

Solution:

  1. Total Rectangles (m=4,n=5m = 4, n = 5):
Nrectangles=(4+12)×(5+12)=(52)×(62)=10×15=150N_{\text{rectangles}} = \binom{4+1}{2} \times \binom{5+1}{2} = \binom{5}{2} \times \binom{6}{2} = 10 \times 15 = 150
  1. Total Squares:
Nsquares=(4×5)+(3×4)+(2×3)+(1×2)=20+12+6+2=40N_{\text{squares}} = (4 \times 5) + (3 \times 4) + (2 \times 3) + (1 \times 2) = 20 + 12 + 6 + 2 = 40
  1. Rectangles Containing Cell (r=2,c=3)(r = 2, c = 3):
    • Top border choices: r=2r = 2; Bottom border choices: 4−2+1=34 - 2 + 1 = 3.
    • Left border choices: c=3c = 3; Right border choices: 5−3+1=35 - 3 + 1 = 3.
Ncontaining (2,3)=(2×3)×(3×3)=6×9=54 rectangles.N_{\text{containing }(2,3)} = (2 \times 3) \times (3 \times 3) = 6 \times 9 = 54\text{ rectangles.}

Worked Example 7.2.2: Shortest Lattice Paths with Checkpoint and Blocked Node

Problem: On a 5×45 \times 4 city street grid (55 blocks East, 44 blocks North from corner A(0,0)A(0,0) to corner B(5,4)B(5,4)), how many shortest paths from AA to BB pass through checkpoint C(2,2)C(2,2) without passing through a closed construction intersection at D(4,3)D(4,3)?

Solution:

  1. Count shortest paths from A(0,0)A(0,0) to C(2,2)C(2,2) (22 East, 22 North):
Paths(A→C)=(2+22)=(42)=6\text{Paths}(A \to C) = \binom{2+2}{2} = \binom{4}{2} = 6
  1. Count all shortest paths from C(2,2)C(2,2) to B(5,4)B(5,4) (33 East, 22 North):
Pathstotal(C→B)=(3+22)=(52)=10\text{Paths}_{\text{total}}(C \to B) = \binom{3+2}{2} = \binom{5}{2} = 10
  1. Subtract paths from C(2,2)C(2,2) to B(5,4)B(5,4) that hit blocked node D(4,3)D(4,3):
    • From C(2,2)C(2,2) to D(4,3)D(4,3) is 22 East, 11 North: (2+11)=3\binom{2+1}{1} = 3 paths.
    • From D(4,3)D(4,3) to B(5,4)B(5,4) is 11 East, 11 North: (1+11)=2\binom{1+1}{1} = 2 paths.
    • Forbidden paths from CC to BB via DD: 3×2=63 \times 2 = 6.
    • Valid paths from CC to BB avoiding DD: 10−6=410 - 6 = 4.
  2. Multiply stages A→CA \to C and C→BC \to B:
Valid Paths=6×4=24\text{Valid Paths} = 6 \times 4 = 24

Review the Method

Shortest paths across an m×nm \times n street grid equal (m+nm)\binom{m+n}{m}, whereas grids with missing road segments or multiple obstacles are solved via Pascal-triangle node addition (Köşe Toplama Yöntemi).

Loading diagram...
Decision Workflow for Shortest Lattice Path Problems on TR-YÖS
Test Your Knowledge

In a 5×65 \times 6 rectangular grid of unit squares (55 rows and 66 columns), how many rectangles can be formed that are NOT squares?

A

210210

B

225225

C

245245

D

315315

Test Your Knowledge

In △ABC\triangle ABC, 44 interior line segments are drawn from apex AA to base BCBC, and 33 additional horizontal line segments are drawn parallel to BCBC across the entire triangle (creating 44 horizontal base lines in total, including BCBC). How many triangles are in the figure?

A

6060

B

4545

C

4040

D

3030

Test Your Knowledge

On a unit-square coordinate grid, the vertices of a shaded triangle lie at A(0,0)A(0, 0), B(6,2)B(6, 2), and C(2,5)C(2, 5). What is the area of △ABC\triangle ABC?

A

11.511.5

B

1212

C

12.512.5

D

1313

Test Your Knowledge

A flat polyomino figure is constructed by gluing 1212 identical unit squares (each of side length 1 cm1\text{ cm}) edge-to-edge such that there are exactly 1515 shared internal unit edges between adjacent squares. Assume the connected figure has no holes. What is its outer perimeter?

A

16 cm16\text{ cm}

B

18 cm18\text{ cm}

C

20 cm20\text{ cm}

D

22 cm22\text{ cm}

Sections you finish are checked off in the contents.