/**
 * This function takes a list of musical notes and a number indicating how many times the block of code 
 * should be executed. It then subtracts the last note from each note in the list, and repeats this process 
 * a certain number of times as specified by the second argument. The updated list is returned as the output.
 */
fun subtractNotes(notesList: List<Int>, numTimes: Int): List<Int> {

    // Check if the input list contains at least 2 notes
    if (notesList.size < 2) {
        return listOf(-1) // Return a list with -1 indicating an error
    }

    // Check if the input number of times is positive
    if (numTimes <= 0) {
        return listOf(-2) // Return a list with -2 indicating an error
    }

    var updatedList = notesList.toMutableList()

    repeat(numTimes) {
        val lastNote = updatedList.last()
        updatedList = updatedList.map { it - lastNote }.toMutableList()
    }

    return updatedList
}
/**
 * This function takes a list of musical notes and a number indicating how many times the block of code 
 * should be executed. It then subtracts the last note from each note in the list, and repeats this process 
 * a certain number of times as specified by the second argument. The updated list is returned as the output.
 */
fun subtractNotes(notesList: List<Int>, numTimes: Int): List<Int> {
/**
 * This function takes a list of musical notes and a number indicating how many times the block of code 
 * should be executed. It then subtracts the last note from each note in the list, and repeats this process 
 * a certain number of times as specified by the second argument. The updated list is returned as the output.
 */
fun subtractNotes(notesList: List<Int>, numTimes: Int): List<Int> {

    // Check if the input list contains at least 2 notes
    if (notesList.size < 2) {
        return listOf(-1) // Return a list with -1 indicating an error
    }

    // Check if the input number of times is positive
    if (numTimes <= 0) {
        return listOf(-2) // Return a list with -2 indicating an error
    }

    var updatedList = notesList.toMutableList()

    repeat(numTimes) {
        val lastNote = updatedList.last()
        updatedList = updatedList.map { it - lastNote }.toMutableList()
    }

    return updatedList
}