Skip to content

Instantly share code, notes, and snippets.

@bobbzorzen
Last active November 13, 2017 16:15
Show Gist options
  • Save bobbzorzen/c13875a57ea7e4adefebe7b10b74b27c to your computer and use it in GitHub Desktop.
Save bobbzorzen/c13875a57ea7e4adefebe7b10b74b27c to your computer and use it in GitHub Desktop.
def find_diagonal_match(matrix, y, x, searchLeft=False):
negator = -1 if searchLeft else 1
match = True
if len(matrix) < y+5 or (len(matrix[y]) < x+5 and x-5 > 0):
match = False
for i in range(1, 5):
if not match:
break
newX = x + (negator*i)
match = matrix[y+i][newX] == matrix[y][x]
return match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment