Fix a bug where the words would be "stuck" to each other end-to-end.

This commit is contained in:
Gonçalo S. Martins 2016-05-18 19:40:52 +01:00
parent 16b1a800b1
commit bf22862ffa

View file

@ -83,14 +83,14 @@ def is_valid(possibility, grid):
if j > 0 and grid[i][j-1] != 0:
return False
# If the succeding space isn't empy
if j+len(word) < len(grid[0])-1 and grid[i][j+len(word)+1] != 0:
if j+len(word) < len(grid[0])-1 and grid[i][j+len(word)] != 0:
return False
if D is "S":
# If the preceding space isn't empty
if i > 0 and grid[i-1][j] != 0:
return False
# If the succeding space isn't empy
if i+len(word) < len(grid)-1 and grid[i+len(word)+1][j] != 0:
if i+len(word) < len(grid)-1 and grid[i+len(word)][j] != 0:
return False
# If we can't find any collisions, it must be okay!