Created
March 31, 2018 10:48
-
-
Save erikseulean/1320571d43b17c0ea25e20cf28515973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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