John Belceto

Greenhorn

Posts: 3

posted 3 years ago

How would you talk through this on paper?

****** ////////////// ****** 0th line

looks like you start with 6 asterisks on each side, and you always have 14 slashes in the middle. right?

***** ////////////\\ ***** 1st line

now you have 5 asterisks and still 14 slashes, but the last 2 of them are the other direction....

Notice a pattern?

for each line, there's a mathematical formula to know both

-how many asterisks = ?

-how many of which direction slashes = ?

solve each equation and you solve your problem. then you should be able to write code.

****** ////////////// ****** 0th line

looks like you start with 6 asterisks on each side, and you always have 14 slashes in the middle. right?

***** ////////////\\ ***** 1st line

now you have 5 asterisks and still 14 slashes, but the last 2 of them are the other direction....

Notice a pattern?

for each line, there's a mathematical formula to know both

-how many asterisks = ?

-how many of which direction slashes = ?

solve each equation and you solve your problem. then you should be able to write code.

When you do things right, people won't be sure you've done anything at all.

It is sorta covered in the JavaRanch Style Guide. |