/**
 * Given a list of nested dictionaries representing actors/actresses and their movies,
 * and a movie name, return a list of actors/actresses who have acted in that movie.
 *
 * The input list is of the following format:
 *
 * actorsList = listOf(
 *     mapOf(
 *         "name" to "Actor1",
 *         "movies" to listOf("Movie1", "Movie2", "Movie3")
 *     ),
 *     mapOf(
 *         "name" to "Actor2",
 *         "movies" to listOf("Movie1", "Movie4", "Movie5")
 *     ),
 *     mapOf(
 *         "name" to "Actor3",
 *         "movies" to listOf("Movie2", "Movie4", "Movie6")
 *     )
 * )
 *
 * Example:
 * --------
 * findActors(actorsList, "Movie1")
 * Output: ["Actor1", "Actor2"]
 */
fun findActors(actorsList: List<Map<String, Any>>, movieName: String): List<String> {

    val actorNames = mutableListOf<String>()
    for (actor in actorsList) {
        if (movieName in actor["movies"] as List<String>) {
            actorNames.add(actor["name"] as String)
        }
    }
    return actorNames
}

val actors = listOf(
    mapOf(
        "name" to "Tom Hanks",
        "movies" to listOf("Forrest Gump", "Cast Away", "Saving Private Ryan")
    )
)
/**
 * Given a list of nested dictionaries representing actors/actresses and their movies,
 * and a movie name, return a list of actors/actresses who have acted in that movie.
 *
 * The input list is of the following format:
 *
 * actorsList = listOf(
 *     mapOf(
 *         "name" to "Actor1",
 *         "movies" to listOf("Movie1", "Movie2", "Movie3")
 *     ),
 *     mapOf(
 *         "name" to "Actor2",
 *         "movies" to listOf("Movie1", "Movie4", "Movie5")
 *     ),
 *     mapOf(
 *         "name" to "Actor3",
 *         "movies" to listOf("Movie2", "Movie4", "Movie6")
 *     )
 * )
 *
 * Example:
 * --------
 * findActors(actorsList, "Movie1")
 * Output: ["Actor1", "Actor2"]
 */
fun findActors(actorsList: List<Map<String, Any>>, movieName: String): List<String> {
/**
 * Given a list of nested dictionaries representing actors/actresses and their movies,
 * and a movie name, return a list of actors/actresses who have acted in that movie.
 *
 * The input list is of the following format:
 *
 * actorsList = listOf(
 *     mapOf(
 *         "name" to "Actor1",
 *         "movies" to listOf("Movie1", "Movie2", "Movie3")
 *     ),
 *     mapOf(
 *         "name" to "Actor2",
 *         "movies" to listOf("Movie1", "Movie4", "Movie5")
 *     ),
 *     mapOf(
 *         "name" to "Actor3",
 *         "movies" to listOf("Movie2", "Movie4", "Movie6")
 *     )
 * )
 *
 * Example:
 * --------
 * findActors(actorsList, "Movie1")
 * Output: ["Actor1", "Actor2"]
 */
fun findActors(actorsList: List<Map<String, Any>>, movieName: String): List<String> {

    val actorNames = mutableListOf<String>()
    for (actor in actorsList) {
        if (movieName in actor["movies"] as List<String>) {
            actorNames.add(actor["name"] as String)
        }
    }
    return actorNames
}

val actors = listOf(
    mapOf(
        "name" to "Tom Hanks",
        "movies" to listOf("Forrest Gump", "Cast Away", "Saving Private Ryan")
    )
)