I did the first bit of the mario pset, but i have no idea where to start for the second part. ive watched the walkthroughs, but im still confused. even if i understand how many hashes and spaces there are per tower line, how do i tell c that "if the height of the tower is __ printf _" i mean, i can't print out a different tower for all 23 of the heights. and i could use a loop construct, but i dont understand how i would use it in this case. any help is appreciated. thanks!

  • Have you tried searching this site for similar related questions? Commented Aug 10, 2014 at 17:17
  • I am also stuck on the same problem set, mario and greed. i am completely new at this so i really need a lot of help, more or less like a step by step direction. Please help me with where and how to start. Thank you.
    – user2879
    Commented Oct 31, 2014 at 5:33

2 Answers 2


Just take some paper and pencil and draw a little to find the way.

Let's take an example of a pyramid of height 4:


(points stand for spaces, just for visibility)

Height: 4
...## Line 1 (3 spaces and 2 hashes)
..### Line 2 (2 spaces and 3 hashes)
.#### Line 3 (1 spaces and 4 hashes)
##### Line 4 (0 spaces and 5 hashes)

As you can see there's a progression in those numbers:

Line 1 - spaces = Line+2 - hashes = Line+1
Line 2 - spaces = Line+1 - hashes = Line+2
Line 3 - spaces = Line+0 - hashes = Line+3
Line 4 - spaces = 0      - hashes = Line+4

Now it's up to you to find a way to implement this kind of progressions. Maybe a for loop for each line, and inside it, a for loop for the spaces and a for loop for hashes can be a solution...


Here's a hint!

For every row r where r is 0-indexed, you have height - r - 1 spaces and r + 2 hashes

If this helps please vote up and mark as accepted

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .