This ruby code generates a pyramid:
w = 20
1.upto(w) { |i| puts ">"+" "*(w-i)+"."*i*2+" "*(w-i)+"<" }
Like so:
> .. <
> .... <
> ...... <
> ........ <
> .......... <
> ............ <
> .............. <
> ................ <
> .................. <
> .................... <
> ...................... <
> ........................ <
> .......................... <
> ............................ <
> .............................. <
> ................................ <
> .................................. <
> .................................... <
> ...................................... <
>........................................<
I want to make the pyramid have one dot at the top instead of two (currently because of "."*i*2 to make it symmetrical).
How can I achieve this?
1 Answer