More teaking to the possibility exclusion rules.

This commit is contained in:
Gonçalo S. Martins 2016-05-18 18:03:16 +01:00
parent 8afbe9cc9a
commit 09d6a2f21c

View file

@ -80,19 +80,14 @@ def is_valid(possibility, grid):
if D is "E":
if j > 0 and grid[i][j-1] != 0:
return False
if grid[i][j+len(word)] != 0:
if j+len(word) < len(grid[0])-1 and grid[i][j+len(word)+1] != 0:
return False
if D is "S":
if i > 0 and grid[i-1][j] != 0:
return False
if grid[i+len(word)][j] != 0:
if i+len(word) < len(grid)-1 and grid[i+len(word)+1][j] != 0:
return False
# Detect proximity
#for k, letter in enumerate(list(word)):
# if D is "E":
# if D is "S":
# If we can't find any collisions, it must be okay!
return True