login
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
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, 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, 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
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
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
Cf. A070886 (Rule 90 = Rule 18, starting with 1).
Sequence in context: A293682 A276651 A374126 * A068845 A324910 A257100
KEYWORD
nonn,tabf
AUTHOR
Benjamin Heiland, Feb 04 2011
STATUS
approved