Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pascal's triangle spacing is off. Need DigitCount?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121204] Re: Pascal's triangle spacing is off. Need DigitCount?
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Sun, 4 Sep 2011 04:12:46 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201109031204.IAA05249@smc.vnet.net>

You could use Grid  in combination with ItemSize instead of Row to give 
all the entries the same width, e.g.

pascalTrngl2[n_] :=
 Module[{max, sp}, max = Max[Table[Binomial[n, j], {j, 0, n}]];
  sp = Round[N[Log[10, max], 5]];
  Column[Table[Grid[{Table[Binomial[i, j], {j, 0, i}]},
     ItemSize -> sp], {i, 0, n}], Center]]

pascalTrngl2[10]

Heike

On 3 Sep 2011, at 14:04, Christopher O. Young wrote:

> I'm trying to get the same spacing between the _center points_ of each of
> the numbers in the Pascal triangle, so that each entry in a row is centered
> properly underneath the corresponding two entries in the row above. Instead,
> all the spacing options for Row[ ] seem to just apply to the spacings
> between numbers.
>
> It looks like I would have to calculate the length (i.e., number of digits)
> of each entry as I go through the table. Is DigitCount the best function to
> use here? I.e., won't slow things down too much? Or is there a faster way?
>
> Thanks for any help.
>
> Chris Young
> cy56 at comcast.net
>
> pascalTrngl2[n_] :=
> Module[
>  {max, sp},
>
>  max = Max[Table[Binomial[n, j], {j, 0, n}]];
>  sp = Round[N[Log[10, max], 5]];
>
>  Column[
>   Table[
>    Row[
>     Table[Binomial[i, j], {j, 0, i}],
>     Invisible[sp]
>     ],
>    {i, 0, n}
>    ],
>   Center
>  ]
> ]
>
>
>





  • Prev by Date: Re: Assembling PDFs into a PDF document?
  • Next by Date: Re: Mathematica collect function,
  • Previous by thread: Re: Pascal's triangle spacing is off. Need DigitCount?
  • Next by thread: Re: Pascal's triangle spacing is off. Need DigitCount?