A2Z Lesson

Log in
← Back to the A2Z sheet

Step 01 Beginner Problems — Patterns

Pattern 16 — Alpha-Ramp Pattern

Easy

A ramp of letters where each row is one letter repeated: 'A', then 'B B', then 'C C C'. The letter climbs the alphabet as you go down while the repetition count climbs with it — both the value and the count are read off the row index.

A
B B
C C C
D D D D
E E E E E
Output for n = 5

How to think about it

Number the rows i = 0, 1, ..., n-1. Row i consists of the single letter chr(ord('A') + i) repeated i + 1 times. Nothing depends on the column at all: within a row every token is identical, so the inner loop degenerates to a repetition. This is Pattern 4 (the repeated-number triangle) translated into letters — value from the row index, count = row index + 1.

Code

The code computes the row's letter once, ch = chr(ord('A') + i), builds a list of i + 1 copies with [ch] * (i + 1), and prints it joined. Because the token is constant within the row, list multiplication replaces the inner loop entirely, just as in Pattern 4.

def pattern(n): for i in range(n): ch = chr(ord("A") + i) print(" ".join([ch] * (i + 1)))

Key points

  • Row i: letter = chr(ord('A') + i), count = i + 1 — both from the row index alone.
  • Constant rows are built with [token] * count; no inner loop needed.
  • This is Pattern 4 with letters — same formulas, character tokens.
  • Row 0 must be a single 'A'; if you see 'B' first, your offset is wrong.
  • The right edge forms a staircase while the letters form a ramp — hence the name.

Suggested questions

Pattern 14 — Increasing Letter Triangle Pattern Letters vary by column there; here they vary only by row — a clean contrast.
Pattern 4 — Right-Angled Number Pyramid II The numeric original: the row number repeated across the row.
Pattern 17 — Alpha-Hill Pattern Letters climb and then descend within each row — the ramp grows a peak.
Factorial of a Given Number ↗ Another build where the step index drives everything that gets produced.

Source note: this lesson follows the structure of Striver's public A2Z DSA course (takeUforward). Each problem links to its original platform, and all problems and content belong to their respective owners — STUDY-BUDDY does not claim ownership of the sheet or its problems, and no permission beyond public linking is claimed.