Arrow · Pattern
Up Arrow
Up Arrow
ArrowSymbol pattern, solid style, size 5. Changing the rubric, style or size above re-shapes the loops — the structure stays identical while only the printed value or the cell filter changes.
Up Arrow · output
Symbol · Solid · size 5
n = 5
for i in range(2 * n - 1):
for j in range(2 * n - 1):
if (i < n and n - 1 - i <= j <= n - 1 + i) or (i >= n and j == n - 1):
print('*', end='')
else:
print(' ', end='')
print()Behind the Scenes Execution
registers · line tracking · call stack · memory regions| Address | Variable | Value |
|---|---|---|
| Stack (4) | ||
| 0x200 | n | 5 |
| 0x204 | i | -1 |
| 0x208 | j | -1 |
| 0x20C | count | 0 |
| String Pool (static) (2) | ||
| 0x400000 | pool["*"] | * |
| 0x400008 | pool["\n"] | \n |
| Heap (9) | ||
| 0x3000 | grid[0] | |
| 0x3020 | grid[1] | |
| 0x3040 | grid[2] | |
| 0x3060 | grid[3] | |
| 0x3080 | grid[4] | |
| 0x30A0 | grid[5] | |
| 0x30C0 | grid[6] | |
| 0x30E0 | grid[7] | |
| 0x3100 | grid[8] | |
Up Arrow
An upward arrow: a pyramid pointing up, followed by a straight shaft column in the remaining rows. It is a pyramid plus a loop that prints one centred column repeatedly.
The size-5 grid
Nine rows in a 9-column frame: the top five rows are the centred pyramid of widths 1, 3, 5, 7, 9, and the last four rows are a one-cell shaft in the centre column 4. The arrow head always uses exactly n rows.
Off-by-one traps
The shaft is n - 1 rows because the pyramid already occupies the first n of the 2n - 1 rows; using n shaft rows makes a 10-row arrow that overflows the frame.
Step by step
- Loop rows i = 0..2n - 2.
- If i < n: print the centred pyramid row (spaces + 2i + 1 values).
- Else: print the shaft — one centred value per row.
- Newline per row.
- Phase two is just a long column — easy after the first phase.
Complexity
When to use it
- Two-phase shapes
- Arrow/pointer diagrams
grid[r] rows in the Heap region and the i / j / count registers on the Stack — every printed character is one write to the grid.Recommended resourcesAffiliate links · may earn us a commission