/**
 * Given a dictionary of actors where the keys are the actors' names and the values are their ages,
 * find the average age of all the actors.
 *
 * @param actorsDict A dictionary where the keys are strings (actors' names) and the values are integers (ages).
 * @return The average age of all the actors in the dictionary.
 */
fun getAverageAge(actorsDict: Map<String, Int>): Double {

    // Initialize variables to store the sum of ages and the count of actors
    var totalAge = 0
    var actorCount = 0

    // Iterate over each actor in the dictionary
    for ((_, age) in actorsDict) {
        // Increment the count of actors
        actorCount++
        // Add the age of the current actor to the total age
        totalAge += age
    }

    // Calculate and return the average age
    return totalAge.toDouble() / actorCount
}

val actors = mapOf(
    "Johnny Depp" to 58,
    "Meryl Streep" to 71,
    "Leonardo DiCaprio" to 46,
    "Tom Hanks" to 65,
    "Jennifer Lawrence" to 30
)

val averageAge = getAverageAge(actors)
/**
 * Given a dictionary of actors where the keys are the actors' names and the values are their ages,
 * find the average age of all the actors.
 *
 * @param actorsDict A dictionary where the keys are strings (actors' names) and the values are integers (ages).
 * @return The average age of all the actors in the dictionary.
 */
fun getAverageAge(actorsDict: Map<String, Int>): Double {
/**
 * Given a dictionary of actors where the keys are the actors' names and the values are their ages,
 * find the average age of all the actors.
 *
 * @param actorsDict A dictionary where the keys are strings (actors' names) and the values are integers (ages).
 * @return The average age of all the actors in the dictionary.
 */
fun getAverageAge(actorsDict: Map<String, Int>): Double {

    // Initialize variables to store the sum of ages and the count of actors
    var totalAge = 0
    var actorCount = 0

    // Iterate over each actor in the dictionary
    for ((_, age) in actorsDict) {
        // Increment the count of actors
        actorCount++
        // Add the age of the current actor to the total age
        totalAge += age
    }

    // Calculate and return the average age
    return totalAge.toDouble() / actorCount
}

val actors = mapOf(
    "Johnny Depp" to 58,
    "Meryl Streep" to 71,
    "Leonardo DiCaprio" to 46,
    "Tom Hanks" to 65,
    "Jennifer Lawrence" to 30
)

val averageAge = getAverageAge(actors)