Skip to content

Instantly share code, notes, and snippets.

@danhyun
Created September 18, 2014 02:10
Show Gist options
  • Select an option

  • Save danhyun/51e76d96eddfea4943b5 to your computer and use it in GitHub Desktop.

Select an option

Save danhyun/51e76d96eddfea4943b5 to your computer and use it in GitHub Desktop.
def is_within_board(location, direction):
"""Tests if the move stays within the boundaries of the board."""
index = (0, 1) [direction in ['right', 'left']]
limit = (0, 4) [direction in ['right', 'down']]
return (location[index] < limit, location[index] > limit) [direction in ['left', 'up']]
@danhyun
Copy link
Author

danhyun commented Sep 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment