# - - - P u z z l e . _ _ c r o s s i n g C l a s h
def __crossingClash ( self, coord, thisSlot, char ):
'''Do the choices for a slot crossing thisSlot clash with char?
[ (coord is a Coord in self) and
(thisSlot is a slot in self containing coord) and
(char is a one-character string, uppercased) ->
if (coord is the intersection of two slots in self)
and (no choices for the slot crossing thisSlot have
choice[charx] in coord's position) ->
return True
else -> return False ]
'''
This method returns True if there is a clash, that
is, if there is a crossing slot and none of its choices have char at the position where the slots cross.
First we check to see if there is an intersecting slot. See Section 34, “Puzzle.whatSlots(): What slots intersect
a given coordinate?” for the method that finds all the
slots that include a given coordinate. We use a list
comprehension to eliminate thisSlot from the result
list. If the resulting list is empty, there is no crossing slot,
so we return False to signify that there is no
clash.
#-- 1 --
# [ slotList := list of slots intersecting coord other
# than thisSlot ]
slotList = [ slot
for slot in self.whatSlots ( coord )
if slot is not thisSlot ]
#-- 2 --
if len(slotList) == 0:
return False
else:
otherSlot = slotList[0]
Next we find the index of coord relative to otherSlot. Then we iterate over all the choices for
otherSlot in self.__wordBank; if any
of those choices has char at that index, we return
False to signify that there is no clash.
#-- 3 --
# [ otherCharx := index in otherSlot of coord ]
otherCharx = otherSlot.findCoord ( coord )
#-- 4 --
# [ if any choice for otherSlot in self.__wordBank has a
# character in position [otherCharx] that matches char ->
# return False
# else -> I ]
for otherChoice in self.__wordBank.genSlotChoices ( otherSlot ):
if otherChoice[otherCharx] == char:
return False
Since no choice for otherSlot has char at the crossing position, return True to signify
that there is a clash.
#-- 5 --
return True