week3/crossword/generate.py
def consistent(self, assignment):
        """
        Return True if `assignment` is consistent (i.e., words fit in crossword
        puzzle without conflicting characters); return False otherwise.
        """
        for variable_x, word_x in assignment.items():
            if variable_x.length != len(word_x):  # check if assigned word is of the proper length for the variable
                return False

            for variable_y, word_y in assignment.items():
                if variable_x != variable_y:
                    # check if the word assigned to variable x is unique (not used in other variables)
                    if word_x == word_y:
                        return False

                    # check if the variables have an overlap in their characters
                    overlap = self.crossword.overlaps[variable_x, variable_y]  # it returns indices where they overlap
                    if overlap:  # if there is an overlap, make sure that the certain character is the same
                        a, b = overlap
                        if word_x[a] != word_y[b]:  # if the characters are different, then it is inconsistent
                            return False

        return True

        Return True if `assignment` is consistent (i.e., words fit in crossword
        puzzle without conflicting characters); return False otherwise.
        
Return True if `assignment` is consistent ; return False otherwise.
Return True if ` assignment ` is consistent ; return False otherwise .
def consistent(self, assignment):
        for variable_x, word_x in assignment.items():
            if variable_x.length != len(word_x):  
                return False
            for variable_y, word_y in assignment.items():
                if variable_x != variable_y:
                    if word_x == word_y:
                        return False
                    overlap = self.crossword.overlaps[variable_x, variable_y]  
                    if overlap:  
                        a, b = overlap
                        if word_x[a] != word_y[b]:  
                            return False
        return True
def consistent ( self , assignment ) : for variable_x , word_x in assignment . items ( ) : if variable_x . length != len ( word_x ) : return False for variable_y , word_y in assignment . items ( ) : if variable_x != variable_y : if word_x == word_y : return False overlap = self . crossword . overlaps [ variable_x , variable_y ] if overlap : a , b = overlap if word_x [ a ] != word_y [ b ] : return False return True
Return True if `assignment` is consistent (i.e., words fit in crossword
puzzle without conflicting characters); return False otherwise.
Return True if ` assignment ` is consistent ( i . e . words fit in crossword puzzle without conflicting characters ) ; return False otherwise .
"""
        Return True if `assignment` is consistent (i.e., words fit in crossword
        puzzle without conflicting characters); return False otherwise.
        """ # check if assigned word is of the proper length for the variable # check if the word assigned to variable x is unique (not used in other variables) # check if the variables have an overlap in their characters # it returns indices where they overlap # if there is an overlap, make sure that the certain character is the same # if the characters are different, then it is inconsistent
self
assignment