Step 01 Beginner Problems — Patterns
Pattern 15 — Reverse Letter Triangle Pattern
The letter triangle of Pattern 14 draining away: the first row runs A through the n-th letter, and every row below drops the final letter, until only 'A' remains. It pairs Pattern 14's character generation with Pattern 6's shrinking count.
A B C D E A B C D A B C A B A
How to think about it
Number the rows i = 0, 1, ..., n-1. Row i has n - i letters: A, B, ..., up to the (n - i)-th letter. The letter at column j is still chr(ord('A') + j) — values come from the column exactly as in Pattern 14 — but the row length now follows the shrinking formula n - i instead of i + 1. Row 0 is the full run A..(n-th letter); the last row (i = n - 1) has length 1 and prints just A.
Code
The code generates letters for j in range(n - i) and joins them. Only the range bound differs from Pattern 14 — a one-token change that flips the triangle from growing to shrinking, which is precisely the lesson: the shape lives in the bounds.
def pattern(n):
for i in range(n):
letters = [chr(ord("A") + j) for j in range(n - i)]
print(" ".join(letters))Key points
- Row i: length = n - i, letters A .. chr(ord('A') + n - i - 1).
- Values still come from the column index; only the row length formula changed.
- First row is the longest (n letters); the last row is the single letter A.
- Patterns 14 and 15 together show i + 1 vs n - i driving identical inner logic.
- The set of rows is the same as Pattern 14's, printed in reverse order.