Skip to content

Instantly share code, notes, and snippets.

@Peilonrayz
Created June 14, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Peilonrayz/acf46dfe7e2bf5745736851efb799abc to your computer and use it in GitHub Desktop.
Save Peilonrayz/acf46dfe7e2bf5745736851efb799abc to your computer and use it in GitHub Desktop.
def calculate_distance(start: Node, end: Node, starts: Set[int]):
turns = 0
position = start.end
while position < end.start:
delta = None
for delta in range(6, 0, -1):
pos = position + delta
if pos not in starts or pos == end.start:
break
else:
return
turns += 1
position += delta
start.edges.append(Edge(turns, end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment