%I #5 Mar 11 2019 20:46:56
%S 0,0,1,0,1,0,-1,0,1,0,-1,0,1,0,-1,-2,-1,0,-1,-2,-3,-2,-1,0,-1,-2,-1,
%T -2,-3,-2,-1,0,1,2,3,4,3,4,5,4,3,4,3,2,1,0,1,0,1,2,1,0,1,0,-1,-2,-1,0,
%U 1,2,1,0,-1,-2,-3,-4,-5,-4,-5,-6,-7,-6,-5,-4,-3,-2
%N a(n) = partial sums of A324672.
%H David Nacin, <a href="/A324692/a324692.png">A324692</a>
%o (Python)
%o import functools
%o #Sequences A324660-A324691 generated by manipulating this trip function
%o #spots - positions in order with possible repetition
%o #flee - positions from which we move away from zero with possible repetition
%o #stuck - positions from which we move to a spot already visited with possible repetition
%o def trip(n):
%o stucklist = list()
%o spotsvisited = [n]
%o leavingspots = list()
%o turn = 0
%o forbidden = {n}
%o while n != 0:
%o turn += 1
%o sign = n // abs(n)
%o st = sign * turn
%o if n - st not in forbidden:
%o n = n - st
%o else:
%o leavingspots.append(n)
%o if n + st in forbidden:
%o stucklist.append(n)
%o n = n + st
%o spotsvisited.append(n)
%o forbidden.add(n)
%o return {'stuck':stucklist, 'spots':spotsvisited,
%o 'turns':turn, 'flee':leavingspots}
%o def sgn(x):
%o if x:
%o return x//abs(x)
%o return 0
%o @functools.lru_cache(maxsize=None)
%o def A324672(n):
%o d = trip(n)
%o mx=max([i for i in d['spots']])
%o mn=min([i for i in d['spots']])
%o return sgn(mx+mn)
%o #Actual sequence
%o def a(n):
%o return sum(A324672(i) for i in range(n))
%Y Cf. A228474, A324660-A324692.
%K sign
%O 0,16
%A _David Nacin_, Mar 11 2019