login
A272577
Number of active (ON, black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 502", based on the 5-celled von Neumann neighborhood.
4
1, 5, 8, 24, 29, 48, 56, 105, 76, 148, 141, 244, 145, 244, 300, 397, 344, 448, 461, 600, 497, 645, 688, 876, 717, 924, 932, 1113, 1008, 1256, 1332, 1372, 1425, 1596, 1576, 1933, 1596, 2004, 2121, 2156, 1988, 2549, 2468, 2600, 2521, 2808, 3149, 3265, 2872
OFFSET
0,2
COMMENTS
Initialized with a single black (ON) cell at stage zero.
REFERENCES
S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 170.
MATHEMATICA
CAStep[rule_, a_]:=Map[rule[[10-#]]&, ListConvolve[{{0, 2, 0}, {2, 1, 2}, {0, 2, 0}}, a, 2], {2}];
code=502; stages=128;
rule=IntegerDigits[code, 2, 10];
g=2*stages+1; (* Maximum size of grid *)
a=PadLeft[{{1}}, {g, g}, 0, Floor[{g, g}/2]]; (* Initial ON cell on grid *)
ca=a;
ca=Table[ca=CAStep[rule, ca], {n, 1, stages+1}];
PrependTo[ca, a];
(* Trim full grid to reflect growth by one cell at each stage *)
k=(Length[ca[[1]]]+1)/2;
ca=Table[Table[Part[ca[[n]][[j]], Range[k+1-n, k-1+n]], {j, k+1-n, k-1+n}], {n, 1, k}];
Map[Function[Apply[Plus, Flatten[#1]]], ca] (* Count ON cells at each stage *)
CROSSREFS
Sequence in context: A270185 A169701 A271008 * A140113 A357117 A368484
KEYWORD
nonn,easy
AUTHOR
Robert Price, May 03 2016
STATUS
approved