Kara draws the triangle row by row, walking alternatively from left to right and from right to left:

currentWidth = 1
left2right = 1

for y in range (0, HEIGHT-1):
  paintRow (currentWidth)
  gotoNextRow (left2right)
  left2right = not left2right
  currentWidth = currentWidth + 2

paintRow (currentWidth)