Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: 1-D Cellular Automata

by gumby (Scribe)
on Jun 19, 2002 at 21:36 UTC ( #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
Node Status?
node history
Node Type: note [id://175847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2019-07-24 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (32 votes). Check out past polls.

    Notices?