def match(pat, lst, ignore=set()):
    """match(pat, lst[, ignore]) -> set
    Finds words in a list that match a given pattern.

    Positional arguments:
    pat (str) -- pattern to match
    lst (list(str)) -- list of strings to search

    Keyword arguments:
    [ignore={}] -- set of words on the list to ignore

    Returns:
    (set(str)) -- set of words in the list that contain the pattern

    This is meant as part of the blacklist rule defining process, where the
    goal is to iteratively choose the rules that exclude the fewest valid
    letter blocks, ignoring any defined exceptions. Here the pattern is the
    considered rule, the list is the set of word blocks, and the ignore-list is
    the set of exceptions. The returned set is the set of valid words that
    would be deleted by the rule.
    """

    # Initialize output set
    out = set()

    # Search each word on the list
    for w in lst:
        # Ignore words in the ignore list
        if w in ignore:
            continue
        # Add to output set if there's a match
        if pat in w:
            out.add(w)

    # Return the set of matches
    return out