This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A272265 #40 Feb 03 2025 18:57:27 %S A272265 1,3,9,21,51,123,285,669,1569,3603,8343,19335,44193,101577,233697, %T A272265 532569,1218345,2789475,6343161,14464101,33004269,74923059,170440203, %U A272265 387945747,879473277,1997066751,4536975315,10273846185 %N A272265 Number of n-step tri-directional self-avoiding walks on the hexagonal lattice. %C A272265 Only 3 directions are allowed, separated by 120 degrees. %C A272265 o %C A272265 x %C A272265 o o %t A272265 mo={{2, 0},{-1, 1}, {-1, -1}}; a[0]=1; %t A272265 a[tg_, p_:{{0, 0}}] := Block[{e, mv = Complement[Last[p]+# & /@ mo, p]}, If[tg == 1, Length@mv, Sum[a[tg-1, Append[p, e]], {e, mv}]]]; %t A272265 a /@ Range[0, 10] %t A272265 (* _Robert FERREOL_, Nov 28 2018; after the program of Giovanni Resta in A001411 *) %o A272265 (Python) %o A272265 def add(L, x): %o A272265 M=[y for y in L]; M.append(x) %o A272265 return(M) %o A272265 plus=lambda L, M : [x+y for x, y in zip(L, M)] %o A272265 mo=[[2, 0], [-1, 1], [-1, -1]] %o A272265 def a(n, P=[[0, 0]]): %o A272265 if n==0: return(1) %o A272265 mv1 = [plus(P[-1], x) for x in mo] %o A272265 mv2=[x for x in mv1 if x not in P] %o A272265 if n==1: return(len(mv2)) %o A272265 else: return(sum(a(n-1, add(P, x)) for x in mv2)) %o A272265 print([a(n) for n in range(11)]) %o A272265 # _Robert FERREOL_, Nov 30 2018 %Y A272265 Cf. A001334. %K A272265 nonn,walk,more %O A272265 0,2 %A A272265 _Francois Alcover_, May 05 2016