04 Try it yourself Interactive

Watch the grid fill one character at a time

The same 5-row pyramid as section 02. Each press of Next advances one step: most steps print exactly one character, the rest open a row or end it. Three things move together: the row being written, the cell receiving the character, and the line of code responsible for it. Switch to the right triangle to see what disappears when a pattern has no leading spaces.

Pyramid
row i: n-i spaces, 2i-1 stars
One whole number, 1 to 9 rows.
Press Next to begin. Each press advances the run by one step.


      
Row i
Inner j
Stars printed0
Spaces printed0
step 0 / 0