/**
 * This exercise requires creating a tuple from a given string, 
 * and then performing a modulus operation on the last element of the tuple.
 * You need to complete the code to solve the exercise.
 *
 * @param string A string containing comma-separated numbers.
 * @return A tuple containing all the numbers extracted from the string, 
 * followed by the modulus of the last element in the tuple with 10.
 */
fun createTupleFromStringAndPerformModulus(string: String): Pair<List<Double>, Double> {

    val numbers = mutableListOf<Double>()
    var currentNumber = ""

    string.forEach { char ->
        when {
            char.isDigit() || char == '.' -> currentNumber += char
            char == ',' -> {
                if (currentNumber.isNotEmpty()) {
                    numbers.add(currentNumber.toDouble())
                    currentNumber = ""
                }
            }
        }
    }

    if (currentNumber.isNotEmpty()) {
        numbers.add(currentNumber.toDouble())
    }

    val lastNumber = numbers.lastOrNull() ?: 0.0
    val result = lastNumber % 10

    return Pair(numbers, result)
}
/**
 * This exercise requires creating a tuple from a given string, 
 * and then performing a modulus operation on the last element of the tuple.
 * You need to complete the code to solve the exercise.
 *
 * @param string A string containing comma-separated numbers.
 * @return A tuple containing all the numbers extracted from the string, 
 * followed by the modulus of the last element in the tuple with 10.
 */
fun createTupleFromStringAndPerformModulus(string: String): Pair<List<Double>, Double> {
/**
 * This exercise requires creating a tuple from a given string, 
 * and then performing a modulus operation on the last element of the tuple.
 * You need to complete the code to solve the exercise.
 *
 * @param string A string containing comma-separated numbers.
 * @return A tuple containing all the numbers extracted from the string, 
 * followed by the modulus of the last element in the tuple with 10.
 */
fun createTupleFromStringAndPerformModulus(string: String): Pair<List<Double>, Double> {

    val numbers = mutableListOf<Double>()
    var currentNumber = ""

    string.forEach { char ->
        when {
            char.isDigit() || char == '.' -> currentNumber += char
            char == ',' -> {
                if (currentNumber.isNotEmpty()) {
                    numbers.add(currentNumber.toDouble())
                    currentNumber = ""
                }
            }
        }
    }

    if (currentNumber.isNotEmpty()) {
        numbers.add(currentNumber.toDouble())
    }

    val lastNumber = numbers.lastOrNull() ?: 0.0
    val result = lastNumber % 10

    return Pair(numbers, result)
}