Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #44 May 09 2020 14:58:59
%S 1,1,1,2,4,7,18,43,93,266,702,1687,5136,14405,36898,117016,341842,
%T 914064,2983027,8972121,24743851,82478973,253555061,715745648,
%U 2424954125,7582390623,21796481477,74805170349,237095926682,691568408221,2398418942361,7686495623620
%N Number of ways to transform a sequence of n ones to a single number by continually removing two numbers and replacing them with their sum modulo 3.
%C Can be considered as the number of maximal chains in a poset whose nodes are the possible states of the sequence. In this sense it counts the same things as A002846 when the elements of that poset are taken modulo 3.
%C Originally this entry had a reference to a paper on the arXiv by Caleb Ji, Enumerative Properties of Posets Corresponding to a Certain Class of No Strategy Games, arXiv:1608.06025 [math.CO], 2016. However, this article has since been removed from the arXiv. - _N. J. A. Sloane_, Sep 07 2018
%H Alois P. Heinz, <a href="/A276027/b276027.txt">Table of n, a(n) for n = 1..1000</a>
%H C. Ji, <a href="/A276027/a276027.jpg">Example for a(7)</a>
%F a(n) = f(0, n, 0) where f(a, b, c) is the number of ways to reach one number beginning with a zeros, b ones, and c twos.
%F Then f(a, b, c) = f_1 + f_2 + f_3 + f_4 where f_1 = f(a-1, b, c) if a>=2 or a, b >=1 or a,c >=1, f_2 = f(a, b-2, c+1) if b >= 2, f_3 = f(a, b+1, c-2) if c >= 2, and f_4 = f(a+1, b-1, c-1) if b, c >= 1, and each are 0 otherwise. Initial terms: f(a, b, c) = 1 for all 1 <= a+b+c <= 2, where a, b, c >= 0.
%e For n = 4, the two ways are 1111 -> 211 -> 10 -> 1 and 1111 -> 211 -> 22 -> 1.
%p b:= proc(x, y, z) option remember;
%p `if`(x+y+z=1, 1, `if`(y>0 and z>0, b(x+1, y-1, z-1), 0)+
%p `if`(x>1 or x>0 and y>0 or x>0 and z>0, b(x-1, y, z), 0)+
%p `if`(y>1, b(x, y-2, z+1), 0)+`if`(z>1, b(x, y+1, z-2), 0))
%p end:
%p a:= n-> b(0, n, 0):
%p seq(a(n), n=1..35); # _Alois P. Heinz_, Aug 18 2016
%t b[x_,y_,z_] := b[x, y, z] = If[x+y+z==1, 1, If[y>0 && z>0, b[x+1, y-1, z-1], 0] + If[x>1 || x>0 && y>0 || x>0 && z>0, b[x-1, y, z], 0] + If[y>1, b[x, y-2, z+1], 0] + If[z>1, b[x, y+1, z-2], 0]]; a[n_]:= b[0, n, 0]; Array[a,35] (* _Jean-François Alcover_, Aug 07 2017, after _Alois P. Heinz_ *)
%o (Python)
%o from sympy.core.cache import cacheit
%o @cacheit
%o def b(x, y, z): return 1 if x + y + z==1 else (b(x + 1, y - 1, z - 1) if y>0 and z>0 else 0) + (b(x - 1, y, z) if x>1 or x>0 and y>0 or x>0 and z>0 else 0) + (b(x, y - 2, z + 1) if y>1 else 0) + (b(x, y + 1, z - 2) if z>1 else 0)
%o def a(n): return b(0, n, 0)
%o print([a(n) for n in range(1, 36)]) # _Indranil Ghosh_, Aug 09 2017, after Maple code
%Y Cf. A002846, A117143.
%Y Similar to A002846 with nodes taken modulo 3.
%Y A117143 is the total number of nodes in this poset.
%K nonn
%O 1,4
%A _Caleb Ji_, Aug 16 2016
%E a(19)-a(32) from _Alois P. Heinz_, Aug 18 2016