/**
 * Given the names of two actors/actresses, [actor1] and [actor2], and a set of movies [movies],
 * the function should return the number of movies they have acted together.
 *
 * @param actor1 The name of the first actor/actress.
 * @param actor2 The name of the second actor/actress.
 * @param movies A set of movies in which actors/actresses have acted.
 * @return The number of movies in which both actors have acted together.
 *
 * Example:
 * actor1 = "Leonardo DiCaprio"
 * actor2 = "Tom Hanks"
 * movies = setOf("Catch Me If You Can", "Inception", "The Terminal", "Forrest Gump")
 * countCommonMovies(actor1, actor2, movies) // Output: 2
 */
fun countCommonMovies(actor1: String, actor2: String, movies: Set<String>): Int {

    var commonMovies = 0
    for (movie in movies) {
        if (actor1 in movie && actor2 in movie) {
            commonMovies++
        }
    }
    return commonMovies
}
/**
 * Given the names of two actors/actresses, [actor1] and [actor2], and a set of movies [movies],
 * the function should return the number of movies they have acted together.
 *
 * @param actor1 The name of the first actor/actress.
 * @param actor2 The name of the second actor/actress.
 * @param movies A set of movies in which actors/actresses have acted.
 * @return The number of movies in which both actors have acted together.
 *
 * Example:
 * actor1 = "Leonardo DiCaprio"
 * actor2 = "Tom Hanks"
 * movies = setOf("Catch Me If You Can", "Inception", "The Terminal", "Forrest Gump")
 * countCommonMovies(actor1, actor2, movies) // Output: 2
 */
fun countCommonMovies(actor1: String, actor2: String, movies: Set<String>): Int {
/**
 * Given the names of two actors/actresses, [actor1] and [actor2], and a set of movies [movies],
 * the function should return the number of movies they have acted together.
 *
 * @param actor1 The name of the first actor/actress.
 * @param actor2 The name of the second actor/actress.
 * @param movies A set of movies in which actors/actresses have acted.
 * @return The number of movies in which both actors have acted together.
 *
 * Example:
 * actor1 = "Leonardo DiCaprio"
 * actor2 = "Tom Hanks"
 * movies = setOf("Catch Me If You Can", "Inception", "The Terminal", "Forrest Gump")
 * countCommonMovies(actor1, actor2, movies) // Output: 2
 */
fun countCommonMovies(actor1: String, actor2: String, movies: Set<String>): Int {

    var commonMovies = 0
    for (movie in movies) {
        if (actor1 in movie && actor2 in movie) {
            commonMovies++
        }
    }
    return commonMovies
}