OFFSET
1,2
COMMENTS
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.
LINKS
Benjamin Heiland, Table of n, a(n) for n = 1..154474
EXAMPLE
Cellular automaton defined by Rule 18 (with sizes in blank space):
(x is a 1 in the automaton, the numbers are the sizes of white spaces)
x ->
x1x ->1
x 3 x ->3
x1x1x1x ->1,1,1
x 7 x ->7
x1x 5 x1x ->1,5,1
x 3 x 3 x 3 x ->3,3,3
x1x1x1x1x1x1x1x ->1,1,1,1,1,1,1
and so on.
PROG
(C)
#include<stdio.h>
#include<stdlib.h>
int main(){
int inumgen; //number of generations
int *iacurrentgen; //current generation
int *ialastgen; //last genereation (to calculate currentgen)
int i=0; //loop counter
int j=0; //another loop counter
int nullcount=0; //used to determinate whitespace size
int a; //a for XOR to get new value
int b; //b for XOR to get new value
iacurrentgen=(int*)calloc(1, sizeof(int));
ialastgen=(int*)calloc(1, sizeof(int));
ialastgen[0]=1;
printf("Calculating A185587\n");
printf("please enter number of generations\n");
printf("note that the number of sequence elements per Generation is fluctuating.\n");
scanf("%d", &inumgen);
i++; //we start at generation1 , not at offset.
while(i<=inumgen){
iacurrentgen=(int*)realloc(iacurrentgen, ((i*2+1)*sizeof(int)));
while(j<(i*2+1)){
if((j-2)<0)
a=0;
else
a=ialastgen[j-2];
if(j>((i-1)*2))
b=0;
else
b=ialastgen[j];
iacurrentgen[j]=(a||b)&&!(a&&b); //(a||b)&&!(a&&b)=aXORb
j++;
}
j=0;
ialastgen=(int*)realloc(ialastgen, ((i*2+1)*sizeof(int)));
while(j<=i*2){
ialastgen[j]=iacurrentgen[j];
if(iacurrentgen[j]==1){
if(nullcount!=0){
printf("%d, ", nullcount);
nullcount=0;
}
}
if(iacurrentgen[j]==0){
nullcount++; }
j++;
}
j=0;
printf("\n");
i++;
}
}
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
Benjamin Heiland, Feb 04 2011
STATUS
approved