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.
    """

    frequencias = dict()
    for file_name, word_list in documents.items():
        for word in word_list:
            if word not in frequencias:
                frequencias[word] = {file_name}
            else:
                frequencias[word].add(file_name)

    for key, value in frequencias.items():
        frequencias[key] = math.log(len(documents) / len(value))

    return frequencias