also why can't i put the row increment above the puts " " * (size - row - 1) + "*" + " " * (row - 1) + "*" it keeps giving me an error when i try that and i can't see why.
If you can help that would be great,
Thanks!

also why can't i put the row increment above the puts " " * (size - row - 1) + "*" + " " * (row - 1) + "*" it keeps giving me an error when i try that and i can't see why.
If you can help that would be great,
Thanks!

I mean below it not above it, it works fine when i put it above it but when i put it below it it errors out

Re: Help with a reverse triangle code

Posted 23 January 2017 - 08:52 PM

Ok I tried to take the negative numbers out, the row += 1 worked now being underneath but it threw the alignment pretty off and I tried to fix it by adding to the strings and than just taking them completely out but it still didn't work. What am I doing wrong now?

Re: Help with a reverse triangle code

Posted 25 January 2017 - 05:26 AM

You don't need to_i, the values are already integers. You just need to ensure that you don't request to multiply by a negative number.

I would have thought it should be possible to adjust the start and end values, and the expressions for the multipliers, so that a negative value isn't generated. It would help to get some graph paper and map out the steps and values that you need for each step.

Re: Help with a reverse triangle code

Posted 26 January 2017 - 03:01 AM

If you understand the code (and the earlier issue with a negative multiplier) and the code works, then it looks fine to me.

As mentioned, I think it is cleaner to have a separate statement for the first line (with a single star) rather than attempting to incorporate it in a single (more complicated) loop. Also, the remaining lines have four parts, so it requires a slightly cumbersome expression.

It is good that you appreciate the importance of refactoring but I would move on; refactoring will become more important when you have something meatier to work with.