login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A185587 Irregular triangle read by rows: row n gives a list of the lengths of the free spaces at the n-th stage in a Rule 18 cellular automaton. 1

%I

%S 1,3,1,1,1,7,1,5,1,3,3,3,1,1,1,1,1,1,1,15,1,13,1,3,11,3,1,1,1,9,1,1,1,

%T 7,7,7,1,5,1,5,1,5,1,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,31,1,

%U 29,1,3,27,3,1,1,1,25,1,1,1,7,23,7,1,5,1,21,1,5,1,3,3,3,19,3,3,3,1,1,1,1,1,1,1,17,1,1,1,1,1,1,1,15,15,15,1,13,1,13,1,13,1,3,11,3,11,3,11,3

%N Irregular triangle read by rows: row n gives a list of the lengths of the free spaces at the n-th stage in a Rule 18 cellular automaton.

%C a(n) is the size of the n^th free space inside the development of a Rule 18 CA (related to logical XOR) on a tape started with a single 1.

%H Benjamin Heiland, <a href="/A185587/b185587.txt">Table of n, a(n) for n = 1..154474</a>

%e Cellular automaton defined by Rule 18 (with sizes in blank space):

%e (x is a 1 in the automaton, the numbers are the sizes of white spaces)

%e x ->

%e x1x ->1

%e x 3 x ->3

%e x1x1x1x ->1,1,1

%e x 7 x ->7

%e x1x 5 x1x ->1,5,1

%e x 3 x 3 x 3 x ->3,3,3

%e x1x1x1x1x1x1x1x ->1,1,1,1,1,1,1

%e and so on.

%o (C)

%o #include<stdio.h>

%o #include<stdlib.h>

%o int main(){

%o int inumgen; //number of generations

%o int *iacurrentgen; //current generation

%o int *ialastgen; //last genereation (to calculate currentgen)

%o int i=0; //loop counter

%o int j=0; //another loop counter

%o int nullcount=0; //used to determinate whitespace size

%o int a; //a for XOR to get new value

%o int b; //b for XOR to get new value

%o iacurrentgen=(int*)calloc(1,sizeof(int));

%o ialastgen=(int*)calloc(1,sizeof(int));

%o ialastgen[0]=1;

%o printf("Calculating A185587\n");

%o printf("please enter number of generations\n");

%o printf("note that the number of sequence elements per Generation is fluctuating.\n");

%o scanf("%d",&inumgen);

%o i++; //we start at generation1 , not at offset.

%o while(i<=inumgen){

%o iacurrentgen=(int*)realloc(iacurrentgen,((i*2+1)*sizeof(int)));

%o while(j<(i*2+1)){

%o if((j-2)<0)

%o a=0;

%o else

%o a=ialastgen[j-2];

%o if(j>((i-1)*2))

%o b=0;

%o else

%o b=ialastgen[j];

%o iacurrentgen[j]=(a||b)&&!(a&&b); //(a||b)&&!(a&&b)=aXORb

%o j++;

%o }

%o j=0;

%o ialastgen=(int*)realloc(ialastgen,((i*2+1)*sizeof(int)));

%o while(j<=i*2){

%o ialastgen[j]=iacurrentgen[j];

%o if(iacurrentgen[j]==1){

%o if(nullcount!=0){

%o printf("%d,",nullcount);

%o nullcount=0;

%o }

%o }

%o if(iacurrentgen[j]==0){

%o nullcount++;}

%o j++;

%o }

%o j=0;

%o printf("\n");

%o i++;

%o }

%o }

%Y Cf. A070886 (Rule 90 = Rule 18, starting with 1).

%K nonn,tabf

%O 1,2

%A _Benjamin Heiland_, Feb 04 2011

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 21 11:18 EDT 2019. Contains 327253 sequences. (Running on oeis4.)