/**
 * You are given a list of artists and a dictionary mapping each artist to a list of their songs.
 * Your task is to find the intersection of the artists and songs, i.e., the artists who have songs in both sets.
 *
 * @param artists A set of artists.
 * @param songs A dictionary mapping each artist to a list of their songs.
 * @return A set containing the artists who have songs in both their own sets and the 'artists' set.
 */
fun artistExercise(artists: Set<String>, songs: Map<String, List<String>>): Set<String> {

    val intersection = mutableSetOf<String>()
    for ((artist, artistSongs) in songs) {
        if (artist in artists) {  // Check if artist is in 'artists' set
            val commonSongs = artistSongs.intersect(artists)  // Find intersection between the artist's songs and 'artists' set
            if (commonSongs.isNotEmpty()) {  // Check if there are common songs
                intersection.add(artist)  // Add artist to intersection set
            }
        }
    }
    return intersection
}
/**
 * You are given a list of artists and a dictionary mapping each artist to a list of their songs.
 * Your task is to find the intersection of the artists and songs, i.e., the artists who have songs in both sets.
 *
 * @param artists A set of artists.
 * @param songs A dictionary mapping each artist to a list of their songs.
 * @return A set containing the artists who have songs in both their own sets and the 'artists' set.
 */
fun artistExercise(artists: Set<String>, songs: Map<String, List<String>>): Set<String> {
/**
 * You are given a list of artists and a dictionary mapping each artist to a list of their songs.
 * Your task is to find the intersection of the artists and songs, i.e., the artists who have songs in both sets.
 *
 * @param artists A set of artists.
 * @param songs A dictionary mapping each artist to a list of their songs.
 * @return A set containing the artists who have songs in both their own sets and the 'artists' set.
 */
fun artistExercise(artists: Set<String>, songs: Map<String, List<String>>): Set<String> {

    val intersection = mutableSetOf<String>()
    for ((artist, artistSongs) in songs) {
        if (artist in artists) {  // Check if artist is in 'artists' set
            val commonSongs = artistSongs.intersect(artists)  // Find intersection between the artist's songs and 'artists' set
            if (commonSongs.isNotEmpty()) {  // Check if there are common songs
                intersection.add(artist)  // Add artist to intersection set
            }
        }
    }
    return intersection
}