Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: 1-D Cellular Automata

by gumby (Scribe)
on Jun 19, 2002 at 21:36 UTC ( [id://175847]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://175847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-29 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found