/**
 * This exercise requires the artist to append new elements to a list and break out of a loop after a certain number of iterations.
 *
 * @param artist The name of the artist.
 * @param elements The initial list of elements.
 * @param maxIterations The maximum number of iterations the loop should execute before breaking.
 * @return The final list of elements after appending new elements.
 */
fun addNewElementsAndBreakLoop(artist: String, elements: MutableList<String>, maxIterations: Int): List<String> {

    // Loop through the elements
    for (index in elements.indices) {
        if (index >= maxIterations) {
            break  // Breaking the loop if maxIterations is reached
        } else {
            val newElement = artist  // Create a new element using the artist's name
            elements.add(newElement)  // Append the new element to the list
        }
    }
    return elements
}

// Example usage
/**
 * This exercise requires the artist to append new elements to a list and break out of a loop after a certain number of iterations.
 *
 * @param artist The name of the artist.
 * @param elements The initial list of elements.
 * @param maxIterations The maximum number of iterations the loop should execute before breaking.
 * @return The final list of elements after appending new elements.
 */
fun addNewElementsAndBreakLoop(artist: String, elements: MutableList<String>, maxIterations: Int): List<String> {
/**
 * This exercise requires the artist to append new elements to a list and break out of a loop after a certain number of iterations.
 *
 * @param artist The name of the artist.
 * @param elements The initial list of elements.
 * @param maxIterations The maximum number of iterations the loop should execute before breaking.
 * @return The final list of elements after appending new elements.
 */
fun addNewElementsAndBreakLoop(artist: String, elements: MutableList<String>, maxIterations: Int): List<String> {

    // Loop through the elements
    for (index in elements.indices) {
        if (index >= maxIterations) {
            break  // Breaking the loop if maxIterations is reached
        } else {
            val newElement = artist  // Create a new element using the artist's name
            elements.add(newElement)  // Append the new element to the list
        }
    }
    return elements
}

// Example usage