import math


def compute_idfs(documents):
    """
    Given a dictionary of `documents` that maps names of documents to a list
    of words, return a dictionary that maps words to their IDF values.

    Any word that appears in at least one of the documents should be in the
    resulting dictionary.
    """
    # Create a set of all the words that exist in the corpus.
    words_in_documents = set([word for words in documents.values() for word in words])

    # Create a dictionary to map each word to its IDF value.
    idfs = dict()
    for word in words_in_documents:
        # Determine the number of documents in the corpus that contain 'word'.
        matched_documents = [
            document for document in documents if word in documents[document]
        ]

        # Determine the IDF value for each word.
        idfs[word] = math.log(len(documents) / len(matched_documents))

    return idfs