hash are declared before the loos, as far as I remember, the
do..while loop is used to get valid input from the user. As per the pset specification page, you should accept heights between 0 and 23 inclusive.
For your approach, I see no obvious reasons for iterating till
tower_height (assuming it's the height you get from the user) is 23.
space == (tower_height - 1) will be evaluated to
tower_height - 1 is not 0 initially! It's correct that relation between the initial number of spaces and the height is as follows
initial spaces = height - 1
but that doesn't mean that we should check if
spaces == (tower_height - 1). Probably we should assign this value to spaces initially before the loops and decrement it accordingly as we move to the next row using a loop to print
space white spaces.
for (int i = 0 to i < space, increment i)
print a whitespace
It's also correct that the initial number of hashes is 2 and the maximum number of hashes is
tower_height + 1, but this also doesn't mean that we should check whether
hash == (tower_height + i). Rather, we should set the initial value of
hash to 2 before the loops and increment it accordingly as we move to the next row using a loop to print
for (int i = 0 to i < hash, increment i)
print a hash