# - - - P u z z l e . _ _ c h o i c e F i t s
def __choiceFits ( self, thisSlot, choice ):
'''Does choice in thisSlot work with its context?
[ (thisSlot is a slot in self) and
(choice is a Word that has the same length as thisSlot) ->
if choice in thisSlot fits the rest of the puzzle
according to self.__wordBank ->
return True
else -> return False ]
'''
The purpose of this method is to check all the slots that
intersect thisSlot, and test to see that all
of the intersecting slots have remaining choices that can
connect with thisSlot at the point of
intersection.
We'll need to know both the index and the coordinate of
each cell in thisSlot, so first we'll
materialize a list of the coordinates so we can iterate
through both the indices and the coordinates using the
list.enumerate() iterator.
#-- 1 --
# [ coordList := list of thisSlot's coordinates in order ]
coordList = [ coord
for coord in thisSlot.genCoords() ]
Now we'll step through the coordinates of thisSlot,
and for each coordinate, if there is another slot crossing thisSlot there, we call Section 46, “Puzzle.__crossingClash(): Does a perpendicular
slot conflict?” to see if the other slot
disqualifies this choice. If there are no clashes with crossing
slots, we return True.
#-- 2 --
# [ if (any Coord in coordList is the intersection of two
# slots) and (no choices of the crossing slot match the
# corresponding letter of (choice) ->
# return False
# else -> I ]
for charx, coord in enumerate(coordList):
#-- 2 body --
# [ 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 False
# else -> I ]
if self.__crossingClash ( coord, thisSlot, choice[charx] ):
return False
#-- 3 --
return True