OFFSET
1,3
COMMENTS
For n = 15, no cycle was found in the first 10^6 iterations. - Giorgos Kalogeropoulos, Nov 08 2021
LINKS
Raghavendra Bhat, A Game of Primes, arXiv:2111.01374 [math.GM], 2021. See Figure 12 p. 11.
MATHEMATICA
Table[M1=Partition[Range[n^2], n]; Ma={#, 0}&/@#&/@MapAt[Reverse, M1, List/@Select[Range@n, EvenQ]]; Neig[x_, y_]:=Ma[[#, #2]]&@@@Select[{x, y}+#&/@Most@Tuples[{1, -1, 0}, 2], Max@#<=n&&Min@#>0&]; F[q_, w_]:=(len=Length@Union@Join[Select[Neig[q, w], PrimeQ@First@#&], Select[Neig[q, w], Last@#==-1&]]; If[Last@Ma[[q, w]]==0, If[len>2, Ma[[q, w]]/. 0->-1, Ma[[q, w]]], If[len>3||len==0, Ma[[q, w]]/. -1->0, Ma[[q, w]]]]); lst={}; i=0; While[FreeQ[lst, Ma], AppendTo[lst, Ma]; Ma=Partition[F@@@Range@n~Tuples~2, n]; i++]; i-First@@Position[lst, Ma]+1, {n, 11}] (* Giorgos Kalogeropoulos, Nov 06 2021 *)
PROG
(PARI) find(nm, v) = {forstep (n=#v-1, 1, -1, if (v[#v] == v[n], return(#v-n); ); ); }
vm(mi, mp, n, i, j) = if ((i<1) || (j<1) || (i>n) || (j>n), 0, mi[i, j] || isprime(mp[i, j]));
nbm(mi, mp, n, i, j) = vm(mi, mp, n, i-1, j-1) + vm(mi, mp, n, i-1, j) + vm(mi, mp, n, i-1, j+1) + vm(mi, mp, n, i, j-1) + vm(mi, mp, n, i, j+1) + vm(mi, mp, n, i+1, j-1) + vm(mi, mp, n, i+1, j) + vm(mi, mp, n, i+1, j+1);
cell(mi, mp, n, i, j) = {my(nb = nbm(mi, mp, n, i, j)); if (mi[i, j], if ((nb>=4) || (nb==0), return (0)); return(1)); return (nb>=3); }
life(mi, mp, n) = matrix(n, n, i, j, cell(mi, mp, n, i, j));
a(n) = {my(mp=matrix(n, n, i, j, if (i%2, n*(i-1)+j, n*i-j+1))); my(mi=matrix(n, n)); my(found = 0); my(list = List()); listput(list, mi); while (! found, my(nmi = life(mi, mp, n)); listput(list, nmi); found = find(nmi, list); mi = nmi; ); found; }
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Michel Marcus, Nov 04 2021
EXTENSIONS
a(13)-a(14) from Giorgos Kalogeropoulos, Nov 08 2021
STATUS
approved