Skip to content

Instantly share code, notes, and snippets.

@erikseulean
Created March 31, 2018 10:48
Show Gist options
  • Select an option

  • Save erikseulean/1320571d43b17c0ea25e20cf28515973 to your computer and use it in GitHub Desktop.

Select an option

Save erikseulean/1320571d43b17c0ea25e20cf28515973 to your computer and use it in GitHub Desktop.
def keyboard_path(word):
path = []
current = 'a'
for letter in word:
x,y = get_position(current)
nx, ny = get_position(letter)
path += math.abs(nx - x) * ['down' if nx > x else 'up']
path += math.abs(ny - y) * ['right' if ny > y else 'left']
current = letter
return path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment