Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
3-axis(x,y,z) Coordinate for Hex system solution in Clear category for Hexagon Spiral by sawako.oono
def hex_spiral(first, second):
"""
Use x,y,z coordinate system for hex.
Then, Manhattan distance between two points are calculated simply as:
max(dx,dw,dz)
"""
x1=[1]
x2=[]
for i in range(20):
x1.append(x1[-1]+i*6+1)
x2.append(x1[-1]+3*(i+1))
x=sorted(x1+x2)
y1=[1]
y2=[]
for i in range(20):
y1.append(y1[-1]+i*6+2)
y2.append(y1[-1]+3*(i+1))
y=sorted(y1+y2)
z1=[1]
z2=[]
for i in range(20):
z1.append(z1[-1]+i*6+3)
z2.append(z1[-1]+3*(i+1))
z=sorted(z1+z2)
cords=[]
for item in (first,second):
for i in range(len(x)-1):
if x[i]<=item
July 6, 2021