- Dec 18, 2010
- 208
- 244
This is something a close friend of mine wrote the other day:
Believe it or not, it actually prints out 1D elementary cellular automata, and takes the cellular automata rule as the first command line argument. If any of you have a C compiler, you can run it with 90 as the first argument and it will print out a nice Sierpinski triangle.
Those of you with programming experience: I apologize for any loss of sanity.
Code:
[FONT="Courier New"]char p,q,r,w[151];
int main(int c,char**v){
int _=151;
r=2^c?0:atoi(v[1]);
while(--_>0)
w[_]=_==75;
while(_++<40&&puts(""))
for(p=c=0;c<150|(q=w[c]);putchar((p=q)?35:32))
w[c]=r&(p?240:15)&(w[c]?204:51)&(w[++c]?170:85);
}[/FONT]
Believe it or not, it actually prints out 1D elementary cellular automata, and takes the cellular automata rule as the first command line argument. If any of you have a C compiler, you can run it with 90 as the first argument and it will print out a nice Sierpinski triangle.
Those of you with programming experience: I apologize for any loss of sanity.