/**
 * In a game, the high scores are stored as a list. You need to update the 
 * existing high scores by appending new elements to the list. 
 *
 * @param scores A list representing the existing high scores.
 * @param newScores An arbitrary number of integers representing the new scores 
 *                  to be added.
 * @return A list of updated high scores, including the new scores, with the 
 *         highest score at the beginning of the list.
 *
 * Example:
 * updateHighScores(listOf(100, 90, 80), 95, 88, 92, 79)
 * [100, 95, 92, 90, 88, 80, 79]
 */
fun updateHighScores(scores: MutableList<Int>, vararg newScores: Int): List<Int> {

    for (newScore in newScores) {
        var indexToInsert = 0  // Initialize the index to insert new score
        for ((i, score) in scores.withIndex()) {
            if (newScore >= score) {
                indexToInsert = i + 1
                break
            }
        }
        scores.add(indexToInsert, newScore)
    }
    return scores
}
/**
 * In a game, the high scores are stored as a list. You need to update the 
 * existing high scores by appending new elements to the list. 
 *
 * @param scores A list representing the existing high scores.
 * @param newScores An arbitrary number of integers representing the new scores 
 *                  to be added.
 * @return A list of updated high scores, including the new scores, with the 
 *         highest score at the beginning of the list.
 *
 * Example:
 * updateHighScores(listOf(100, 90, 80), 95, 88, 92, 79)
 * [100, 95, 92, 90, 88, 80, 79]
 */
fun updateHighScores(scores: MutableList<Int>, vararg newScores: Int): List<Int> {
/**
 * In a game, the high scores are stored as a list. You need to update the 
 * existing high scores by appending new elements to the list. 
 *
 * @param scores A list representing the existing high scores.
 * @param newScores An arbitrary number of integers representing the new scores 
 *                  to be added.
 * @return A list of updated high scores, including the new scores, with the 
 *         highest score at the beginning of the list.
 *
 * Example:
 * updateHighScores(listOf(100, 90, 80), 95, 88, 92, 79)
 * [100, 95, 92, 90, 88, 80, 79]
 */
fun updateHighScores(scores: MutableList<Int>, vararg newScores: Int): List<Int> {

    for (newScore in newScores) {
        var indexToInsert = 0  // Initialize the index to insert new score
        for ((i, score) in scores.withIndex()) {
            if (newScore >= score) {
                indexToInsert = i + 1
                break
            }
        }
        scores.add(indexToInsert, newScore)
    }
    return scores
}