[Edu-sig] Pascal's Triangle (in 2.6)

kirby urner kirby.urner at gmail.com
Sat Jan 30 21:26:47 CET 2010


On Sat, Jan 30, 2010 at 11:21 AM, Edward Cherlin <echerlin at gmail.com> wrote:
> Pascal's Triangle mod 2 is also a Sierpinski gasket fractal. This is
> one of the Python examples in Pippy in the Sugar education software.
>

Glad to see OLPC is getting the right stuff here.

Your technique of backing everything with a rectangular array of 'O's, to
be replaced by " ", "." or left alone, is a great way of formatting.  You use
"print comma" (print ,) to keep going on the line, no newline character
before we're done in that loop.

The same matting technique could be used for any rule-based row-by-row
generating scheme, ala the Wolfram numbering using a bit pattern to
encode the next permutation.  I've done some work in this area in collaboration
with other contributors to this archive (John Zelle, Gregor Lingl).

4dsolutions.net/ocn/python/nks.py
http://4dsolutions.net/ocn/python/canvas3.py

(note our back ending into PIL, Zelle's graphics.py or Gregor's wrapper for
TkCanvas).

Your use of a matte also mirrors my recent suggestion regarding building
a "color sniffing" turtle that stores a shared "canvas" object in some array,
perhaps of just integers, or RGB 3-tuples, if that's the only data we care
about (in addition to geographic position).

Turtles all read and write to the same matte through a handle (easy in
Python as the default is to not copy).

I did run it with gusto.  Might've been a dot missing lower right?

>>>
                .
              .   .
            .   O   .
          .   .   .   .
        .   O   O   O   .
      .   .   O   O   .   .
    .   O   .   O   .   O   .
  .   .   .   .   .   .   .   .
>>>

Great work.

Kirby

PS:

<geometry type="esoteric">

Pascal's is coming up in my research because I'm trying to do some
technical writing about one David Koski's studies.  He builds hexahedra
(zonohedral rhomb-faced) from great circle networks, packs them out to
the first spherical polyhedron, is finding some pattern in Pascal's that
predicts how many.

Example, when you use 10 mid-face axials of the icosahedron as a
set of spokes from the origin, illuminate any three not at 180 degrees,
you get successive corners of hexahedra, I think he said only 10
possible?

You get a rhombic dodecahedron inside the enneacontahedron that
way (as one of the zonohedra).  You get cubes inside the great
rhombicosadodecahedron.  Hope I got that right, will double check
with DAve.

The resulting spherical polyhedra may not have all rhombic faces however
as "zero volume" flattened hexahedra, predicted by Pascal's, come together
in the form of other polygons.  Here are a couple examples:

http://www.flickr.com/photos/17157315@N00/4279038891/in/set-72157622797118549/
(132 sides)

http://www.flickr.com/photos/17157315@N00/4311083958/in/set-72157622797118549/
(600 sides)

http://mybizmo.blogspot.com/2008/11/enneacontahedron.html
(older study)

</geometry>

> # Sierpinski triangles
> import sys
> size = 3
> modulus = 2
>
> lines = modulus**size
>
> vector = [1]
> for i in range(1,lines+1):
>  vector.insert(0,0)
>  vector.append(0)
>
> for i in range(0,lines):
>  newvector = vector[:]
>  for j in range(0,len(vector)-1):
>    if (newvector[j] == 0):
>      print " ",
>    else:
>      remainder = newvector[j] % modulus
>      if (remainder == 0):
>        print "O",
>      else:
>        print ".",
>    newvector[j] = vector[j-1] + vector[j+1]
>  print
>  vector = newvector[:]
>
> On Sat, Jan 30, 2010 at 12:23, kirby urner <kirby.urner at gmail.com> wrote:
>
> This process below is how I learned Pascal's Triangle from my mother
> when I was 11.
>

<< SNIP >>

> --
> Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://www.earthtreasury.org/
>


More information about the Edu-sig mailing list