From: "M. Edward (Ed) Borasky" Date: 2006-06-25T06:15:25+09:00 Subject: Re: [QUIZ] pp Pascal (#84) brian.mattern@gmail.com wrote: > On Sun, Jun 25, 2006 at 12:03:17AM +0900, Erik Veenstra wrote: > >> The only problem with this is that you need to know the maximum >> cell width (on the last row) when you build the first one. So I >> iterate twice over all rows. The first time to determine the >> last row and its biggest cell and the second time to format and >> print each row. >> > > Its fairly easy to calculate the maximum digit in the triangle without > calculating all the rows (basically O(N)). > > (think binomial coefficients) > If you've got a really wide screen, think Stirling's approximation. :) -- M. Edward (Ed) Borasky http://linuxcapacityplanning.com