/**
 * This function takes a list, an index, and a new value as arguments
 * and replaces the element at the given index with the new value.
 *
 * @param list The list to be modified.
 * @param index The index of the element to be replaced.
 * @param newValue The new value to be inserted at the given index.
 * @return The modified list with the element replaced.
 */
fun replaceElements(list: MutableList<Int>, index: Int, newValue: Int): List<Int> {

    try {
        list[index] = newValue
    } catch (e: IndexOutOfBoundsException) {
        return listOf(-1) // Indicate index out of range with a placeholder value
    }
    return list
}

// Electrician's task: Replace the faulty switch (element) in the list
/**
 * This function takes a list, an index, and a new value as arguments
 * and replaces the element at the given index with the new value.
 *
 * @param list The list to be modified.
 * @param index The index of the element to be replaced.
 * @param newValue The new value to be inserted at the given index.
 * @return The modified list with the element replaced.
 */
fun replaceElements(list: MutableList<Int>, index: Int, newValue: Int): List<Int> {
/**
 * This function takes a list, an index, and a new value as arguments
 * and replaces the element at the given index with the new value.
 *
 * @param list The list to be modified.
 * @param index The index of the element to be replaced.
 * @param newValue The new value to be inserted at the given index.
 * @return The modified list with the element replaced.
 */
fun replaceElements(list: MutableList<Int>, index: Int, newValue: Int): List<Int> {

    try {
        list[index] = newValue
    } catch (e: IndexOutOfBoundsException) {
        return listOf(-1) // Indicate index out of range with a placeholder value
    }
    return list
}

// Electrician's task: Replace the faulty switch (element) in the list