- # on the previous column
- if col > 0 and self.data[row+i][col-1].occupied_down is True:
- raise IntersectWordException (word, len(word))
- # on the next column
- if (col < (len(word) - 1) and
- (self.data[row+i][col+1].occupied_down is True or
- self.data[row+i][col+1].across_start is True)):
- raise IntersectWordException (word, len(word))
+ # on the previous column except first column
+ if col > 0:
+ # except the first and last col
+ if i > 0 and i < len(word) - 1:
+ if self.data[row+i][col-1].occupied_down is True:
+ raise IntersectWordException (word, len(word))
+ # on the next column except last column
+ if col < len(word) - 1:
+ # except the first and last row check if there is any
+ # down word in previous column
+ if i > 0 and i < len(word) - 1:
+ if self.data[row+i][col+1].occupied_down is True:
+ raise IntersectWordException (word, len(word))
+ # check if there is any across word starting in the
+ # next column
+ if self.data[row+i][col+1].across_start is True:
+ raise IntersectWordException (word, len(word))