OFFSET
1,3
LINKS
Jens Ahlström, Table of n, a(n) for n = 1..10000
EXAMPLE
Path begins:
25--24--23--22--21--20--19 Y=3
| |
26 9--10--11--12--13 18 Y=2
| | | |
27 8 5---4---3 14 17 Y=1
| | | | | |
28 7---6 1---2 15--16 Y=0
----------------------------
X = -3 -2 -1 0 1 2 3
For n=8, the path has come to the point (-2, 1), which has the Manhattan distance a(8) = abs(-2) + abs(1) = 3.
PROG
(Python)
def traverse_upper_halfplane(n):
points = [(0, 0)]
arch = 1
sign = 1
while len(points) < n:
for y in range(arch+1):
points.append((sign*arch, y))
for x in range(arch-1, -arch-1, -1):
points.append((sign*x, arch))
for y in range(arch-1, -1, -1):
points.append((-sign*arch, y))
arch += 1
sign = - sign
return points[:n]
l = [abs(x)+y for (x, y) in traverse_upper_halfplane(91)]
print(l)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jens Ahlström, Oct 01 2025
STATUS
approved
