/**
 * This function takes an input list and appends new elements to it after performing slicing operation.
 *
 * @param inputList The list to be sliced and appended with new elements.
 * @param newElements The elements to be appended into the list.
 * @return The updated list after slicing and appending.
 *
 * Example:
 * inputList = [1, 2, 3, 4, 5]
 * newElements = [6, 7, 8]
 *
 * sliceAndAppend(inputList, newElements) -> [1, 2, 3, 6, 7, 8]
 */
fun sliceAndAppend(inputList: MutableList<Int>, newElements: List<Int>): List<Int> {

    // Perform slicing to get the first half of the input list
    val firstHalf = inputList.subList(0, inputList.size / 2).toMutableList()

    // Perform slicing to get the second half of the input list
    val secondHalf = inputList.subList(inputList.size / 2, inputList.size).toMutableList()

    // Append newElements to the first half of the list
    firstHalf.addAll(newElements)

    // Append the second half of the list after the newly appended elements
    firstHalf.addAll(secondHalf)

    return firstHalf
}
/**
 * This function takes an input list and appends new elements to it after performing slicing operation.
 *
 * @param inputList The list to be sliced and appended with new elements.
 * @param newElements The elements to be appended into the list.
 * @return The updated list after slicing and appending.
 *
 * Example:
 * inputList = [1, 2, 3, 4, 5]
 * newElements = [6, 7, 8]
 *
 * sliceAndAppend(inputList, newElements) -> [1, 2, 3, 6, 7, 8]
 */
fun sliceAndAppend(inputList: MutableList<Int>, newElements: List<Int>): List<Int> {
/**
 * This function takes an input list and appends new elements to it after performing slicing operation.
 *
 * @param inputList The list to be sliced and appended with new elements.
 * @param newElements The elements to be appended into the list.
 * @return The updated list after slicing and appending.
 *
 * Example:
 * inputList = [1, 2, 3, 4, 5]
 * newElements = [6, 7, 8]
 *
 * sliceAndAppend(inputList, newElements) -> [1, 2, 3, 6, 7, 8]
 */
fun sliceAndAppend(inputList: MutableList<Int>, newElements: List<Int>): List<Int> {

    // Perform slicing to get the first half of the input list
    val firstHalf = inputList.subList(0, inputList.size / 2).toMutableList()

    // Perform slicing to get the second half of the input list
    val secondHalf = inputList.subList(inputList.size / 2, inputList.size).toMutableList()

    // Append newElements to the first half of the list
    firstHalf.addAll(newElements)

    // Append the second half of the list after the newly appended elements
    firstHalf.addAll(secondHalf)

    return firstHalf
}