def check_b4_adding(word, gpat, ypat, unused):
    """
    Return True if:
        gpat indicates that a letter is green and a letter does not match
        ypat indicates that a letter is yellow and this letter matches or
            this letter is not found in the word
        the letter matches a letter known to be unused

    @param word String word to check
    @param gpat String Green pattern
    @param ypat String yellow pattern
    @param unused String unused letters
    @return True/False
    """
    bad = False
    for indx, letter in enumerate(gpat):
        if letter != '':
            if letter != word[indx]:
                return True
    for indx, ylets in enumerate(ypat):
        if ylets != '':
            for ltr in ylets:
                if ltr == word[indx]:
                    return True
                if ltr not in word:
                    return True
    for letter in word:
        if letter in unused:
            bad = True
            break
    return bad