/**
 * Given a list of numbers and a target number, this function appends all the elements from the numbers
 * list to a new list until the target number is reached. Once the target number is found in the numbers
 * list, it stops appending elements and returns the new list.
 *
 * Example:
 * numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * target = 4
 *
 * The new list should contain [1, 2, 3, 4].
 */
fun appendAndBreak(numbers: List<Int>, target: Int): List<Int> {

    val newList = mutableListOf<Int>()

    // Iterate through numbers list
    for (num in numbers) {
        // Append the current number to the new list
        newList.add(num)

        if (num == target) {
            break
        }
    }

    return newList
}
/**
 * Given a list of numbers and a target number, this function appends all the elements from the numbers
 * list to a new list until the target number is reached. Once the target number is found in the numbers
 * list, it stops appending elements and returns the new list.
 *
 * Example:
 * numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * target = 4
 *
 * The new list should contain [1, 2, 3, 4].
 */
fun appendAndBreak(numbers: List<Int>, target: Int): List<Int> {
/**
 * Given a list of numbers and a target number, this function appends all the elements from the numbers
 * list to a new list until the target number is reached. Once the target number is found in the numbers
 * list, it stops appending elements and returns the new list.
 *
 * Example:
 * numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * target = 4
 *
 * The new list should contain [1, 2, 3, 4].
 */
fun appendAndBreak(numbers: List<Int>, target: Int): List<Int> {

    val newList = mutableListOf<Int>()

    // Iterate through numbers list
    for (num in numbers) {
        // Append the current number to the new list
        newList.add(num)

        if (num == target) {
            break
        }
    }

    return newList
}