From b9bc318095b4e8b213abb4ab25656f400e2fd9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=2E=20Martins?= Date: Wed, 18 May 2016 13:10:24 +0100 Subject: [PATCH] Slight tweak to the exclusion rules. --- crossword_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crossword_generator.py b/crossword_generator.py index 300ad1a..0ad2e3c 100755 --- a/crossword_generator.py +++ b/crossword_generator.py @@ -65,7 +65,7 @@ def is_valid(possibility, grid): return False # Proximity if grid[i][j+k] != letter: - if (i < len(grid) - 1 and grid[i+1][j+k] != 0) or (i > 0 and grid[i-1][j+k]): + if (i < len(grid) - 1 and grid[i+1][j+k] != 0) or (i > 0 and grid[i-1][j+k] != 0): return False if D is "S": # Collisions @@ -73,7 +73,7 @@ def is_valid(possibility, grid): return False # Proximity if grid[i+k][j] != letter: - if (j < len(grid[0]) - 1 and grid[i+k][j+1] != 0) or (i > 0 and grid[i+k][j-1]): + if (j < len(grid[0]) - 1 and grid[i+k][j+1] != 0) or (i > 0 and grid[i+k][j-1] != 0): return False # Start and End