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 A360594 #32 Jan 12 2024 10:05:39 %S A360594 0,2,1,2,4,3,8,1,2,2,4,2,8,5,4,6,13,14,14,13,13,16,22,3,17,16,20,13, %T A360594 13,24,22,15,24,15,14,17,14,4,15,18,23,26,28,13,16,30,28,14,15,17,16, %U A360594 19,16,33,18,33,32,35,39,38,40,38,39,39,36,39,38,39,41,52 %N A360594 a(n) is the maximum number of locations 0..n-1 which can be visited in a single path starting from i=n-1, where jumps from location i to i +- a(i) are permitted (within 0..n-1) and each location can be visited up to 2 times. %C A360594 When a location is visited more than once, each such visit counts in a(n). %e A360594 For n=0 there are no locations 0..n-1, so the sole possible path is empty which is a(0) = 0 locations. %e A360594 For n=1, the sole possible path is location 0 twice, 0 -> 0, which is 2 locations a(1) = 2. %e A360594 For n=12, a path of a(12) = 8 locations visited starting from n-1 = 11 is: %e A360594 11 -> 9 -> 11 -> 9 -> 7 -> 8 -> 10 -> 6 %e A360594 Locations 11 and 9 are visited twice each and the others once. %e A360594 i = 0 1 2 3 4 5 6 7 8 9 10 11 %e A360594 a(i) = 0, 2, 1, 2, 4, 3, 8, 1, 2, 2, 4, 2 %e A360594 2<----2 %e A360594 ---->2 %e A360594 1<----2<---- %e A360594 ->2---->4 %e A360594 8<---------- %o A360594 (Python) %o A360594 def A(lastn,times=2,mode=0): %o A360594 a,n=[0],0 %o A360594 while n<lastn: %o A360594 d,i,v,o,g,r=[[n]],0,1,[],0,0 %o A360594 while len(d)>0: %o A360594 if len(d[-1])>v: v,o=len(d[-1]),d[-1][:] %o A360594 if d[-1][-1]-a[d[-1][-1]]>=0: %o A360594 if d[-1].count(d[-1][-1]-a[d[-1][-1]])<times:g=1 %o A360594 if d[-1][-1]+a[d[-1][-1]]<=n: %o A360594 if d[-1].count(d[-1][-1]+a[d[-1][-1]])<times: %o A360594 if g>0: d.append(d[-1][:]) %o A360594 d[-1].append(d[-1][-1]+a[d[-1][-1]]) %o A360594 r=1 %o A360594 if g>0: %o A360594 if r>0: d[-2].append(d[-2][-1]-a[d[-2][-1]]) %o A360594 else: d[-1].append(d[-1][-1]-a[d[-1][-1]]) %o A360594 r=1 %o A360594 if r==0: d.pop() %o A360594 r,g=0,0 %o A360594 a.append(v) %o A360594 n+=1 %o A360594 if mode==0: print(n,a[n]) %o A360594 if mode>0: %o A360594 u,q=0,[] %o A360594 while u<len(o): %o A360594 q.append(a[o[u]]) %o A360594 u+=1 %o A360594 print(n,a[n],q,o) %o A360594 return a %Y A360594 Cf. A360593, A360595. %K A360594 nonn %O A360594 0,2 %A A360594 _S. Brunner_, Feb 13 2023