/**
 * This function appends new elements to an existing array based on the values of a nested list.
 * The nested list consists of triplets: [element, depth, repetitions].
 * The element represents the value that will be appended to the array.
 * The depth represents the level at which the element will be appended.
 * The repetitions indicate how many times the element will be appended at that level.
 *
 * @param array The original array to which new elements will be appended.
 * @param nestedList The nested list containing the elements to be appended and their corresponding depths and repetitions.
 * @return The updated array with the appended elements.
 */
fun appendNestedElements(array: MutableList<Int>, nestedList: List<Triple<Int, Int, Int>>): MutableList<Int> {

    for (triplet in nestedList) {
        val (element, depth, repetitions) = triplet

        repeat(repetitions) {
            repeat(depth) {
                array.add(element)
            }
        }
    }

    return array
}
/**
 * This function appends new elements to an existing array based on the values of a nested list.
 * The nested list consists of triplets: [element, depth, repetitions].
 * The element represents the value that will be appended to the array.
 * The depth represents the level at which the element will be appended.
 * The repetitions indicate how many times the element will be appended at that level.
 *
 * @param array The original array to which new elements will be appended.
 * @param nestedList The nested list containing the elements to be appended and their corresponding depths and repetitions.
 * @return The updated array with the appended elements.
 */
fun appendNestedElements(array: MutableList<Int>, nestedList: List<Triple<Int, Int, Int>>): MutableList<Int> {
/**
 * This function appends new elements to an existing array based on the values of a nested list.
 * The nested list consists of triplets: [element, depth, repetitions].
 * The element represents the value that will be appended to the array.
 * The depth represents the level at which the element will be appended.
 * The repetitions indicate how many times the element will be appended at that level.
 *
 * @param array The original array to which new elements will be appended.
 * @param nestedList The nested list containing the elements to be appended and their corresponding depths and repetitions.
 * @return The updated array with the appended elements.
 */
fun appendNestedElements(array: MutableList<Int>, nestedList: List<Triple<Int, Int, Int>>): MutableList<Int> {

    for (triplet in nestedList) {
        val (element, depth, repetitions) = triplet

        repeat(repetitions) {
            repeat(depth) {
                array.add(element)
            }
        }
    }

    return array
}