/**
 * This exercise aims to help physical therapists calculate the sum of values within a range of numbers.
 *
 * @param ranges a list of tuples representing the ranges, where each tuple contains the start and end values.
 * @return The sum of all numbers within the given ranges.
 *
 * Example:
 * sumOfRanges(listOf(Pair(1, 5), Pair(10, 15), Pair(20, 25))) // 120
 * sumOfRanges(listOf(Pair(2, 4), Pair(7, 10), Pair(15, 18))) // 46
 */
fun sumOfRanges(ranges: List<Pair<Int, Int>>): Int {

    var totalSum = 0  // Initialize the variable to hold the sum
    
    // Iterate through each range
    for (range in ranges) {
        // Calculate the sum using the range function and addition
        for (i in range.first..range.second) {
            totalSum += i
        }
    }
    
    return totalSum
}
/**
 * This exercise aims to help physical therapists calculate the sum of values within a range of numbers.
 *
 * @param ranges a list of tuples representing the ranges, where each tuple contains the start and end values.
 * @return The sum of all numbers within the given ranges.
 *
 * Example:
 * sumOfRanges(listOf(Pair(1, 5), Pair(10, 15), Pair(20, 25))) // 120
 * sumOfRanges(listOf(Pair(2, 4), Pair(7, 10), Pair(15, 18))) // 46
 */
fun sumOfRanges(ranges: List<Pair<Int, Int>>): Int {
/**
 * This exercise aims to help physical therapists calculate the sum of values within a range of numbers.
 *
 * @param ranges a list of tuples representing the ranges, where each tuple contains the start and end values.
 * @return The sum of all numbers within the given ranges.
 *
 * Example:
 * sumOfRanges(listOf(Pair(1, 5), Pair(10, 15), Pair(20, 25))) // 120
 * sumOfRanges(listOf(Pair(2, 4), Pair(7, 10), Pair(15, 18))) // 46
 */
fun sumOfRanges(ranges: List<Pair<Int, Int>>): Int {

    var totalSum = 0  // Initialize the variable to hold the sum
    
    // Iterate through each range
    for (range in ranges) {
        // Calculate the sum using the range function and addition
        for (i in range.first..range.second) {
            totalSum += i
        }
    }
    
    return totalSum
}