/**
 * This exercise requires the Physical Therapist to calculate the distance between two points in a stretch exercise.
 * The stretchLengths parameter is a list of integers representing the different lengths of stretches in centimeters.
 * The index parameter is an integer representing the index of the first stretch.
 *
 * Complete the code below to calculate the distance between the first stretch and the stretch at the given index,
 * taking into account the lengths of the stretches in between.
 *
 * Remember that you can use the indices to iterate over the stretches and their indexes.
 *
 * Example:
 * For stretchLengths = [10, 15, 12, 8, 20, 17] and index = 4,
 * the distance should be calculated as the sum of the lengths of stretches from index 0 to index 3.
 */
fun calculateDistance(stretchLengths: List<Int>, index: Int): Int {

    var distance = 0

    // Calculate the distance by summing the lengths of the stretches from index 0 to index (index - 1)
    for (i in 0 until index) {
        distance += stretchLengths[i]
    }

    return distance
}
/**
 * This exercise requires the Physical Therapist to calculate the distance between two points in a stretch exercise.
 * The stretchLengths parameter is a list of integers representing the different lengths of stretches in centimeters.
 * The index parameter is an integer representing the index of the first stretch.
 *
 * Complete the code below to calculate the distance between the first stretch and the stretch at the given index,
 * taking into account the lengths of the stretches in between.
 *
 * Remember that you can use the indices to iterate over the stretches and their indexes.
 *
 * Example:
 * For stretchLengths = [10, 15, 12, 8, 20, 17] and index = 4,
 * the distance should be calculated as the sum of the lengths of stretches from index 0 to index 3.
 */
fun calculateDistance(stretchLengths: List<Int>, index: Int): Int {
/**
 * This exercise requires the Physical Therapist to calculate the distance between two points in a stretch exercise.
 * The stretchLengths parameter is a list of integers representing the different lengths of stretches in centimeters.
 * The index parameter is an integer representing the index of the first stretch.
 *
 * Complete the code below to calculate the distance between the first stretch and the stretch at the given index,
 * taking into account the lengths of the stretches in between.
 *
 * Remember that you can use the indices to iterate over the stretches and their indexes.
 *
 * Example:
 * For stretchLengths = [10, 15, 12, 8, 20, 17] and index = 4,
 * the distance should be calculated as the sum of the lengths of stretches from index 0 to index 3.
 */
fun calculateDistance(stretchLengths: List<Int>, index: Int): Int {

    var distance = 0

    // Calculate the distance by summing the lengths of the stretches from index 0 to index (index - 1)
    for (i in 0 until index) {
        distance += stretchLengths[i]
    }

    return distance
}