# - - - P u z z l e . _ _ r e d u c e C e l l
def __reduceCell ( self, cell ):
'''Eliminate any choices not common to two intersecting slots.
[ cell is a Cell in self ->
if cell is related to two slots ->
self.__wordBank := self.__wordBank -
(choices for those slots that have letters at
cell's position not found in the intersecting
slot)
else -> I ]
'''
if VERBOSE:
print "=== Reduce cell %s" % cell.coord
#-- 1 --
# [ if two slots intersect at cell ->
# slotSet := a list containing those two slots as
# Slot instances
# else -> return ]
slotSet = [ slot
for slot in cell.genSlots() ]
if len(slotSet) < 2:
return
Next, we interrogate the WordBank instance to find the
set of all possible characters that could occur at the given cell;
see Section 72, “WordBank.cellChoices(): What characters
are choices at a given coordinate?”.
#-- 2 --
# letterSet := a set of one-character strings representing
# possible choices at cell ]
letterSet = self.__wordBank.cellChoices ( cell.coord )
if len(letterSet) == 0:
print "@@@ Empty choices at %s" % cell.coord
self.showAllChoices()
fatal("No choices during Puzzle-reduceSlot")
if VERBOSE: print "=== Choices:", ''.join(list(letterSet))
Finally, eliminate any choices that have letters at this cell's
position that are not in letterSet; see
Section 41, “Puzzle.__reduceSlot(): Eliminate choices
for one slot”.
#-- 3 --
# [ self.__wordBank := self.__wordBank - (choices for
# slots in slotSet whose characters at cell's position
# are not in letterSet ]
for slot in slotSet:
#-- 3 body --
# [ self.__wordBank := self.__wordBank - (choices for
# slot whose characters at cell's position
# are not in letterSet ]
self.__reduceSlot ( cell, slot, letterSet )