/**
 * This function takes in two tuples and an integer, and returns a new tuple that is obtained by concatenating tup1 and
 * tup2. The elements of the new tuple are repeated based on the given repeat value.
 *
 * @param tup1 First tuple to concatenate.
 * @param tup2 Second tuple to concatenate.
 * @param repeat Number of times to repeat the elements in the new tuple.
 * @return New tuple obtained by concatenating tup1 and tup2, and repeating its elements.
 *
 * Example:
 * concatenateRepeatTuples(listOf('A', 'B'), listOf('C', 'D'), 3) -> ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']
 */
fun concatenateRepeatTuples(tup1: List<Any>, tup2: List<Any>, repeat: Int): List<Any> {

    val concatenatedList = tup1 + tup2
    val repeatedList = concatenatedList.flatMap { List(repeat) { it } }
    return repeatedList
}
/**
 * This function takes in two tuples and an integer, and returns a new tuple that is obtained by concatenating tup1 and
 * tup2. The elements of the new tuple are repeated based on the given repeat value.
 *
 * @param tup1 First tuple to concatenate.
 * @param tup2 Second tuple to concatenate.
 * @param repeat Number of times to repeat the elements in the new tuple.
 * @return New tuple obtained by concatenating tup1 and tup2, and repeating its elements.
 *
 * Example:
 * concatenateRepeatTuples(listOf('A', 'B'), listOf('C', 'D'), 3) -> ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']
 */
fun concatenateRepeatTuples(tup1: List<Any>, tup2: List<Any>, repeat: Int): List<Any> {
/**
 * This function takes in two tuples and an integer, and returns a new tuple that is obtained by concatenating tup1 and
 * tup2. The elements of the new tuple are repeated based on the given repeat value.
 *
 * @param tup1 First tuple to concatenate.
 * @param tup2 Second tuple to concatenate.
 * @param repeat Number of times to repeat the elements in the new tuple.
 * @return New tuple obtained by concatenating tup1 and tup2, and repeating its elements.
 *
 * Example:
 * concatenateRepeatTuples(listOf('A', 'B'), listOf('C', 'D'), 3) -> ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']
 */
fun concatenateRepeatTuples(tup1: List<Any>, tup2: List<Any>, repeat: Int): List<Any> {

    val concatenatedList = tup1 + tup2
    val repeatedList = concatenatedList.flatMap { List(repeat) { it } }
    return repeatedList
}