in reply to 1-D Cellular Automata

Sierpinski sieve:
#!/usr/bin/perl -wl $_="co"; while (1) { s/..(?=c)/$&^"CO"/eg; s/^/ /; print; }
Now, why does this work? Because binom(m, n)(mod 2) = n XOR m, so this is just Pascal's triangle (mod 2).

Update: Will work now.

Replies are listed 'Best First'.
Re: Re: 1-D Cellular Automata
by RMGir (Prior) on Jun 20, 2002 at 12:36 UTC
    why does this work?

    It doesn't, at least, not with 5.6.1, or 5.005_03.

    Does it need 5.8?

    Edit: As petral points out, the regex will never match. I should have noticed that myself, instead of just trying the code...
    --
    Mike

      $_="co" will never match /..(?=c)/.

        p