close
login
A389352
Manhattan distance to the origin of point n while traversing the half plane by integer points in rectangular layers starting from n=1 at the origin.
5
0, 1, 2, 1, 2, 1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6
OFFSET
1,3
LINKS
FORMULA
a(n) = |A389649(n)| + A389648(n).
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
Cf. A213088 (quadrant), A214526 (whole plane), A389648 (Y), A389649 (X).
Sequence in context: A317586 A303780 A234022 * A261273 A097454 A139803
KEYWORD
nonn,easy
AUTHOR
Jens Ahlström, Oct 01 2025
STATUS
approved