posted 5 months ago
If you want to avoid all these nasty space-jugglings :
Form a variable s = String[rows][cols] with cols = 4 * rows - 3 and rows = say 10;
Fill the array with " " (or " ".repeat(3));
initialise:
currentRow = rows - 1;
deltax = 1;
And then use one loop:
from col = 0 to cols;
set s[currentRow][col] to " * ";
test: if currentRow == 0 or currentRow == rows - 1 then deltax = -deltax;
currentrow += deltax;
Finally print s.
There are three kinds of actuaries: those who can count, and those who can't.