@@ -27,8 +27,8 @@ def is_trapped_in_wall(
2727): # true if cell is trapped of walls
2828 north = (cell .coordinate [0 ] - 1 , cell .coordinate [1 ])
2929 south = (cell .coordinate [0 ] + 1 , cell .coordinate [1 ])
30- west = (cell .coordinate [0 ], cell .coordinate [1 ] - 1 )
3130 east = (cell .coordinate [0 ], cell .coordinate [1 ] + 1 )
31+ west = (cell .coordinate [0 ], cell .coordinate [1 ] - 1 )
3232
3333 coord = (cell .coordinate [0 ], cell .coordinate [1 ])
3434
@@ -41,6 +41,14 @@ def is_trapped_in_wall(
4141 return {west , south }.issubset (wall_coord )
4242 if coord == (height - 1 , width - 1 ): # bottom right corner
4343 return {north , west }.issubset (wall_coord )
44+ if coord [0 ] == 0 : # for cells at top row
45+ return {south , west , east }.issubset (wall_coord )
46+ if coord [1 ] == 0 : # for cells at leftmost column
47+ return {north , south , east }.issubset (wall_coord )
48+ if coord [0 ] == height - 1 : # for cells at the bottom row
49+ return {north , east , west }.issubset (wall_coord )
50+ if coord [1 ] == width - 1 : # for cells at rightmost column
51+ return {north , south , west }.issubset (wall_coord )
4452
4553 return {north , south , west , east }.issubset (wall_coord )
4654
0 commit comments