/**
 * This function takes in a set of historians and a dictionary of their works,
 * and returns a new dictionary with the works of each historian as values.
 * The function also identifies the intersection of historians present in the set
 * and in the keys of the dictionary.
 *
 * @param historianSet A set containing the names of historians.
 * @param historianDict A dictionary with historians as keys and their works as values.
 * @return A new dictionary with the works of each historian as values.
 */
fun combineData(historianSet: Set<String>, historianDict: Map<String, List<String>>): Map<String, List<String>> {

    val intersections = mutableMapOf<String, List<String>>()
    for (historian in historianSet) {  // Loop through the given set of historians
        var works = emptyList<String>()
        if (historian in historianDict) {  // Check if historian exists in the dictionary
            for ((key, value) in historianDict) {  // Loop through the keys of the dictionary
                if (key == historian) {
                    works = value
                    break
                }
            }
            intersections[historian] = works
        }
    }
    return intersections
}
/**
 * This function takes in a set of historians and a dictionary of their works,
 * and returns a new dictionary with the works of each historian as values.
 * The function also identifies the intersection of historians present in the set
 * and in the keys of the dictionary.
 *
 * @param historianSet A set containing the names of historians.
 * @param historianDict A dictionary with historians as keys and their works as values.
 * @return A new dictionary with the works of each historian as values.
 */
fun combineData(historianSet: Set<String>, historianDict: Map<String, List<String>>): Map<String, List<String>> {
/**
 * This function takes in a set of historians and a dictionary of their works,
 * and returns a new dictionary with the works of each historian as values.
 * The function also identifies the intersection of historians present in the set
 * and in the keys of the dictionary.
 *
 * @param historianSet A set containing the names of historians.
 * @param historianDict A dictionary with historians as keys and their works as values.
 * @return A new dictionary with the works of each historian as values.
 */
fun combineData(historianSet: Set<String>, historianDict: Map<String, List<String>>): Map<String, List<String>> {

    val intersections = mutableMapOf<String, List<String>>()
    for (historian in historianSet) {  // Loop through the given set of historians
        var works = emptyList<String>()
        if (historian in historianDict) {  // Check if historian exists in the dictionary
            for ((key, value) in historianDict) {  // Loop through the keys of the dictionary
                if (key == historian) {
                    works = value
                    break
                }
            }
            intersections[historian] = works
        }
    }
    return intersections
}