The first thing I would do is ask how many rows the user wanted to generate. This will tell me two pieces of valuable information. The first is what the largest number in the triangle will be. If you are not sure why this is, I will remind you of the relationship between Pascal's Triangle and combinatorials (C = N choose K). The second piece of information is how many leading units you need for the first row. What do you mean by unit you ask - read on.
The next thing I would do is determine the length of the largest number in the triangle. This will become 1 unit. Every value (space or number) will be this wide. This will make the triangle look as smooth as possible (assuming monospace font).
Finally, I would start filling in each row. Filling up the leading white space units and then placing each number. Each number will need to be centered in the unit - probably using sprintf. If the triangle still does not look smooth it is probably a result of imperfect centering. You may be able to remedy this by varying which side to leave the extra space on (round robin, random, odd/even, etc).
You probably already have your solution and have moved on but if you would like to really spend some time learning perl - please feel free to ask questions and we will help you out as best as we can.
Cheers - L~R
In reply to Re: Equilateral Pascal's Triangle in perltex
by Limbic~Region
in thread Equilateral Pascal's Triangle in perltex
by Coach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |