/**
 * You have been given the following information:
 *
 * - 'actor': A tuple containing the first names of four actors
 * - 'actress': A tuple containing the first names of four actresses
 * - 'dictionary': A dictionary that contains the names of actors as keys and their corresponding genders as values.
 *
 * Your task is to perform the following steps:
 *
 * 1. Concatenate the 'actor' and 'actress' tuples to form a single tuple called 'combined'.
 * 2. Repeat the 'combined' tuple three times and store the result in a variable called 'repeated'.
 * 3. Modify the 'dictionary' by adding the 'repeated' tuple as values for each actor. The actor names should remain as keys.
 * 4. Finally, return the updated 'dictionary'.
 *
 * Complete the function below to solve the exercise.
 */
fun concatenateTupleRepeatModify(actor: List<String>, actress: List<String>, dictionary: MutableMap<String, List<String>>): MutableMap<String, List<String>> {

    val combined = actor + actress
    val repeated = combined.repeat(3)

    for (key in dictionary.keys) {
        dictionary[key] = repeated
    }

    return dictionary
}

fun List<String>.repeat(n: Int): List<String> {
    return List(n) { this }.flatten()
}
/**
 * You have been given the following information:
 *
 * - 'actor': A tuple containing the first names of four actors
 * - 'actress': A tuple containing the first names of four actresses
 * - 'dictionary': A dictionary that contains the names of actors as keys and their corresponding genders as values.
 *
 * Your task is to perform the following steps:
 *
 * 1. Concatenate the 'actor' and 'actress' tuples to form a single tuple called 'combined'.
 * 2. Repeat the 'combined' tuple three times and store the result in a variable called 'repeated'.
 * 3. Modify the 'dictionary' by adding the 'repeated' tuple as values for each actor. The actor names should remain as keys.
 * 4. Finally, return the updated 'dictionary'.
 *
 * Complete the function below to solve the exercise.
 */
fun concatenateTupleRepeatModify(actor: List<String>, actress: List<String>, dictionary: MutableMap<String, List<String>>): MutableMap<String, List<String>> {
/**
 * You have been given the following information:
 *
 * - 'actor': A tuple containing the first names of four actors
 * - 'actress': A tuple containing the first names of four actresses
 * - 'dictionary': A dictionary that contains the names of actors as keys and their corresponding genders as values.
 *
 * Your task is to perform the following steps:
 *
 * 1. Concatenate the 'actor' and 'actress' tuples to form a single tuple called 'combined'.
 * 2. Repeat the 'combined' tuple three times and store the result in a variable called 'repeated'.
 * 3. Modify the 'dictionary' by adding the 'repeated' tuple as values for each actor. The actor names should remain as keys.
 * 4. Finally, return the updated 'dictionary'.
 *
 * Complete the function below to solve the exercise.
 */
fun concatenateTupleRepeatModify(actor: List<String>, actress: List<String>, dictionary: MutableMap<String, List<String>>): MutableMap<String, List<String>> {

    val combined = actor + actress
    val repeated = combined.repeat(3)

    for (key in dictionary.keys) {
        dictionary[key] = repeated
    }

    return dictionary
}

fun List<String>.repeat(n: Int): List<String> {
    return List(n) { this }.flatten()
}