/**
 * This function takes in the names of two actors, a dictionary of movies they have worked in, and returns
 * a set of movies that both actors have worked in.
 */
fun findCommonMovies(actor1: String, actor2: String, movies: Map<String, List<String>>): Set<String> {

    // Create two empty sets to store the movies of each actor
    val actor1Movies = mutableSetOf<String>()
    val actor2Movies = mutableSetOf<String>()

    // Use loops to iterate through the movies dictionary and add the movies of each actor to their respective sets
    for ((movie, actors) in movies) {
        if (actor1 in actors) {
            actor1Movies.add(movie)
        }
        if (actor2 in actors) {
            actor2Movies.add(movie)
        }
    }

    // Use set intersection to find the common movies between the two actors
    val commonMovies = actor1Movies.intersect(actor2Movies)

    return commonMovies
}
/**
 * This function takes in the names of two actors, a dictionary of movies they have worked in, and returns
 * a set of movies that both actors have worked in.
 */
fun findCommonMovies(actor1: String, actor2: String, movies: Map<String, List<String>>): Set<String> {
/**
 * This function takes in the names of two actors, a dictionary of movies they have worked in, and returns
 * a set of movies that both actors have worked in.
 */
fun findCommonMovies(actor1: String, actor2: String, movies: Map<String, List<String>>): Set<String> {

    // Create two empty sets to store the movies of each actor
    val actor1Movies = mutableSetOf<String>()
    val actor2Movies = mutableSetOf<String>()

    // Use loops to iterate through the movies dictionary and add the movies of each actor to their respective sets
    for ((movie, actors) in movies) {
        if (actor1 in actors) {
            actor1Movies.add(movie)
        }
        if (actor2 in actors) {
            actor2Movies.add(movie)
        }
    }

    // Use set intersection to find the common movies between the two actors
    val commonMovies = actor1Movies.intersect(actor2Movies)

    return commonMovies
}