|
|
A324692
|
|
a(n) = partial sums of A324672.
|
|
33
|
|
|
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, -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, 1, 2, 1, 0, -1, -2, -3, -4, -5, -4, -5, -6, -7, -6, -5, -4, -3, -2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,16
|
|
LINKS
|
|
|
PROG
|
(Python)
import functools
#Sequences A324660-A324691 generated by manipulating this trip function
#spots - positions in order with possible repetition
#flee - positions from which we move away from zero with possible repetition
#stuck - positions from which we move to a spot already visited with possible repetition
def trip(n):
stucklist = list()
spotsvisited = [n]
leavingspots = list()
turn = 0
forbidden = {n}
while n != 0:
turn += 1
sign = n // abs(n)
st = sign * turn
if n - st not in forbidden:
n = n - st
else:
leavingspots.append(n)
if n + st in forbidden:
stucklist.append(n)
n = n + st
spotsvisited.append(n)
forbidden.add(n)
return {'stuck':stucklist, 'spots':spotsvisited,
'turns':turn, 'flee':leavingspots}
def sgn(x):
if x:
return x//abs(x)
return 0
@functools.lru_cache(maxsize=None)
d = trip(n)
mx=max([i for i in d['spots']])
mn=min([i for i in d['spots']])
return sgn(mx+mn)
#Actual sequence
def a(n):
return sum(A324672(i) for i in range(n))
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|