/**
 * Given three actors and a list of movies, find the intersection of movies they have acted in.
 *
 * @param actor1 a string representing the name of the first actor
 * @param actor2 a string representing the name of the second actor
 * @param actor3 a string representing the name of the third actor
 * @param movies a list of strings representing the movies
 * @return a list of strings representing the common movies they have acted in
 */
fun findCommonMovies(actor1: String, actor2: String, actor3: String, movies: List<String>): List<String> {

    val commonMovies = mutableListOf<String>()

    for (movie in movies) {
        // Check if actor1 has acted in the movie
        if (actor1 in movie) {
            // Check if actor2 has also acted in the movie
            if (actor2 in movie) {
                // Check if actor3 has also acted in the movie
                if (actor3 in movie) {
                    commonMovies.add(movie)
                    // Continue to the next movie without checking the remaining conditions
                    continue
                }
            }
        }
    }

    return commonMovies
}
/**
 * Given three actors and a list of movies, find the intersection of movies they have acted in.
 *
 * @param actor1 a string representing the name of the first actor
 * @param actor2 a string representing the name of the second actor
 * @param actor3 a string representing the name of the third actor
 * @param movies a list of strings representing the movies
 * @return a list of strings representing the common movies they have acted in
 */
fun findCommonMovies(actor1: String, actor2: String, actor3: String, movies: List<String>): List<String> {
/**
 * Given three actors and a list of movies, find the intersection of movies they have acted in.
 *
 * @param actor1 a string representing the name of the first actor
 * @param actor2 a string representing the name of the second actor
 * @param actor3 a string representing the name of the third actor
 * @param movies a list of strings representing the movies
 * @return a list of strings representing the common movies they have acted in
 */
fun findCommonMovies(actor1: String, actor2: String, actor3: String, movies: List<String>): List<String> {

    val commonMovies = mutableListOf<String>()

    for (movie in movies) {
        // Check if actor1 has acted in the movie
        if (actor1 in movie) {
            // Check if actor2 has also acted in the movie
            if (actor2 in movie) {
                // Check if actor3 has also acted in the movie
                if (actor3 in movie) {
                    commonMovies.add(movie)
                    // Continue to the next movie without checking the remaining conditions
                    continue
                }
            }
        }
    }

    return commonMovies
}