Skip to content

Instantly share code, notes, and snippets.

@daaray
Created October 20, 2019 19:58
Show Gist options
  • Save daaray/cb87368d11771ae093fe1ac366848563 to your computer and use it in GitHub Desktop.
Save daaray/cb87368d11771ae093fe1ac366848563 to your computer and use it in GitHub Desktop.
for x in range(1 - end):
choices = []
for y in [y-1, y, y+1]:
choices.append({
'x': x, 'y': y, 'delta': abs(elevation - self.matrix[y][x])
})
min_delta = min([choice['delta'] for choice in choices])
next_step = next((item for item in choices if item['delta'] == min_delta), None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment