A359303 Bitwise encoding of the state of a 1D cellular automaton after n steps from ...111000... where adjacent cells swap 01 <-> 10 when within triples 110 or 011.
1, 3, 5, 11, 13, 39, 43, 45, 103, 155, 171, 173, 359, 411, 619, 669, 1367, 1371, 1387, 1437, 3287, 4923, 5339, 5467, 5483, 5533, 11479, 13115, 19675, 21339, 21739, 21853, 43735, 43835, 44251, 45915, 52459, 78685, 170455, 173755, 174555, 174811, 174939, 175339, 176989, 367063, 419515, 629211
Offset: 1
Examples
For n=1, the starting state steps by a single swap, marked (), and the resulting string excluding left ...1110 is the bits of a(1) = 1, start ...11110000... () a(1) = 1 = ...11101000... \---> bits 100... Conflicting swaps are seen at n=2 in pattern 11011. Its 101 is unchanged, but the right 11 is also part of a 110 and it does swap, a(2) = 3 = ...11110110000... CCC() a(3) = 5 = ...11110101000... \---> bits 101... = 5 Bit encoding direction, least- to most-significant, is seen at n=5, a(5) = 13 = ...1111010110000... \---> bits 1011 Overlapping swaps in pattern 0110 are seen at n=8, a(8) = 45 = ...111101011010000... () ()() a(9) = 103 = ...1111011100110000...
Links
- Raphael J. F. Berger, Table of n, a(n) for n = 1..1000
- Kevin Ryde, PARI/GP Code
- Eric Wastl, Advent of Code 2022, day 23
Programs
-
Mathematica
ClearAll[{s,prop,checkprop,doprop,run,p,pa,a,j}]; prop[s_]:=(p=Array[0#&,Length[s]]; Do[If[i==1 ||i==Length[s],p[[i]]=0, {p[[i-1]],p[[i]],p[[i+1]]}+= Piecewise[{{{1,-1,0},{s[[i-1]],s[[i]],s[[i+1]]}=={0,1,1}}, {{0,-1,1},{s[[i-1]],s[[i]],s[[i+1]]}=={1,1,0}}},{0,0,0}]],{i,1,Length[s]-1} ]; Return[p]) checkprop[s_]:=(p=s; Do[If[p[[i]]==2,{p[[i-1]],p[[i]],p[[i+1]]}={0,0,0}],{i,2,Length[s]-1}]; Return[p]) doprop[s_]:= Return[s +checkprop[prop[s]]] (* the cellular automaton starting with n+5 "1" cells and n+5 "0" cells *) run[n_]:=( s=Join[Array[#/#&,n+5],Array[0#&,n+5]] ;Table[Nest[doprop[#]&,s,k],{k,0,n}]) (*conversion from the automaton states to integers *) (* a[10] returns {1,3,5,11,13,39,43,45,103} *) a[j_]:=Table[FromDigits[Reverse[run[j+1][[k,All]]/.{Longest[1 ...], x___} :> {x}],2]/2,{k,2,j+1}]
-
PARI
\\ See links.
Comments