%I #24 Oct 01 2022 21:15:07
%S 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,15,15,15,15,15,15,15,15,15,
%T 15,15,15,15,15,15,16,17,18,18,18,18,19,20,21,22,22,22,22,22,22,22,22,
%U 22,22,22,22,22,22,22,22,22,22,22,23,24,25,26,27,28,28
%N a(n) is the number of distinct Q-toothpicks after the n-th stage of the structure described in A211000.
%C See A211000 for additional information.
%C For the definition of Q-toothpicks, see A187210.
%H N. J. A. Sloane, <a href="/wiki/Catalog_of_Toothpick_and_CA_Sequences_in_OEIS">Catalog of Toothpick and Cellular Automata Sequences in the OEIS</a>
%H <a href="/index/To#toothpick">Index entries for sequences related to toothpick sequences</a>
%e In the following diagrams the A211000 structure is shown at the end of the n-th stage (Q-toothpicks are depicted as straight lines instead of circle arcs).
%e .
%e n 0 1 10 15 32 39 60 65
%e a(n) 0 1 10 15 16 20 23 28
%e .
%e /\
%e \/
%e \
%e / /
%e / /\ /\
%e \ \/ \/
%e / /\ /\ /\ /\/\ /\/\ /\/\
%e \ \ \/ \/ \/ \/
%e \ /\ /\ /\ /\ /\
%e / \/ \/ \/ \/ \/
%e / /\ /\ /\ /\ /\
%e \ \/ \/ \/ \/ \/
%e \ /\ /\ /\ /\ /\
%e \/ \/ \/ \/ \/ \/
%e .
%t A357434[nmax_]:=Module[{a={0},tp={},ep1={0,0},ep2,angle=0,turn=Pi/2},Do[If[!PrimeQ[n],If[n>5&&PrimeQ[n-1],turn*=-1];angle-=turn];tp=Union[tp,{{ep1,ep2=AngleVector[ep1,angle]}}];ep1=ep2;AppendTo[a,Length[tp]],{n,0,nmax-1}];a];
%t A357434[100]
%o (PARI)
%o A357434(nmax) = my(a=List([0,1]), newtp=[[0, 0], [1, 1]], tp=Set([newtp]), turn=1, p1, p2); if(nmax==0, return([0]));for(n=1, nmax-1, p1=newtp[1]; p2=newtp[2]; if(isprime(n), newtp=[p2, [2*p2[1]-p1[1], 2*p2[2]-p1[2]]], if(n>5 && isprime(n-1), turn*=-1); newtp=[p2, [p2[1]-turn*(p1[2]-p2[2]), p2[2]+turn*(p1[1]-p2[1])]]); tp=setunion(tp, [newtp]); listput(a,length(tp))); Vec(a);
%o A357434(100)
%o (Python)
%o from sympy import isprime
%o def A357434(nmax):
%o newtp, a, turn = ((0, 0), (1, 1)), [0, 1], 1
%o tp = {newtp}
%o for n in range(1, nmax):
%o p1, p2 = newtp[0], newtp[1]
%o if isprime(n): # Continue straight
%o newtp = (p2, (2*p2[0]-p1[0], 2*p2[1]-p1[1]))
%o else: # Turn
%o if n>5 and isprime(n-1): turn *= -1
%o newtp = (p2, (p2[0]-turn*(p1[1]-p2[1]), p2[1]+turn*(p1[0]-p2[0])))
%o tp.add(newtp)
%o a.append(len(tp))
%o return a[:nmax+1]
%o print(A357434(100))
%Y Cf. A187210, A211000, A355479.
%K nonn
%O 0,3
%A _Paolo Xausa_, Sep 28 2022