import re


def flatMapFunc(document):
    """
    Before we returned a list of words and used the map and reduce fucntions to
    determine how many times each word occurred (regardless of document ID).
    Now we want to know how many different documents contain the word.

    This function should create a list of items which we will then run various
    transformations on to eventually create a count of documents per word.

    document[0] is the document ID (distinct for each document)
    document[1] is a string of all text in that document

    You will need to modify this code.
    """
    documentID = document[0]
    words = re.findall(r"\w+", document[1])
    ret = []
    for i in words:
        ret.append((i, documentID))
    return ret