Skip to content

Instantly share code, notes, and snippets.

@molarmanful
Last active September 18, 2019 19:29
Show Gist options
  • Save molarmanful/a18bac9fd4c64c7dafe0ace2b90bc09b to your computer and use it in GitHub Desktop.
Save molarmanful/a18bac9fd4c64c7dafe0ace2b90bc09b to your computer and use it in GitHub Desktop.
def move(d):
if d == 'up' and POS - COLS >= 0:
POS -= COLS
if d == 'down' and POS + COLS < ROWS * COLS:
POS += COLS
if d == 'left' and POS % COLS:
POS -= 1
if d == 'right' and (POS + 1) % COLS:
POS += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment