/**
 * Given a list of tuples, each containing two floats, write a function that calculates the average of the second elements
 * of all tuples where the first element is greater than the second element.
 *
 * Example:
 * averageOfGreaterTuples(listOf(1.2 to 0.8, 2.5 to 1.9, 3.1 to 2.5, 0.7 to 0.9)) returns 2.2
 */
fun averageOfGreaterTuples(tuples: List<Pair<Double, Double>>): Double {

    var sumOfGreater = 0.0
    var count = 0

    for (tup in tuples) {
        if (tup.first > tup.second) {
            sumOfGreater += tup.second
            count++
        }
    }

    return if (count > 0) sumOfGreater / count else 0.0
}
/**
 * Given a list of tuples, each containing two floats, write a function that calculates the average of the second elements
 * of all tuples where the first element is greater than the second element.
 *
 * Example:
 * averageOfGreaterTuples(listOf(1.2 to 0.8, 2.5 to 1.9, 3.1 to 2.5, 0.7 to 0.9)) returns 2.2
 */
fun averageOfGreaterTuples(tuples: List<Pair<Double, Double>>): Double {
/**
 * Given a list of tuples, each containing two floats, write a function that calculates the average of the second elements
 * of all tuples where the first element is greater than the second element.
 *
 * Example:
 * averageOfGreaterTuples(listOf(1.2 to 0.8, 2.5 to 1.9, 3.1 to 2.5, 0.7 to 0.9)) returns 2.2
 */
fun averageOfGreaterTuples(tuples: List<Pair<Double, Double>>): Double {

    var sumOfGreater = 0.0
    var count = 0

    for (tup in tuples) {
        if (tup.first > tup.second) {
            sumOfGreater += tup.second
            count++
        }
    }

    return if (count > 0) sumOfGreater / count else 0.0
}