/**
 * Given a list of tuples representing the positions of elements in a grid, write a function to find the average
 * positions of the elements using loop control statements and slicing.
 *
 * @param arr A list of tuples representing the positions of elements in a grid. Each tuple contains two integers.
 * @return A tuple representing the average position of the elements in the grid, rounded to the nearest integer.
 */
fun loopSlicingExercise(arr: List<Pair<Int, Int>>): Pair<Int, Int> {

    var totalX = 0
    var totalY = 0
    var count = 0

    for (position in arr) {
        val x = position.first
        val y = position.second

        totalX += x
        totalY += y
        count++
    }

    val avgX = totalX / count
    val avgY = totalY / count

    return Pair(avgX, avgY)
}
/**
 * Given a list of tuples representing the positions of elements in a grid, write a function to find the average
 * positions of the elements using loop control statements and slicing.
 *
 * @param arr A list of tuples representing the positions of elements in a grid. Each tuple contains two integers.
 * @return A tuple representing the average position of the elements in the grid, rounded to the nearest integer.
 */
fun loopSlicingExercise(arr: List<Pair<Int, Int>>): Pair<Int, Int> {
/**
 * Given a list of tuples representing the positions of elements in a grid, write a function to find the average
 * positions of the elements using loop control statements and slicing.
 *
 * @param arr A list of tuples representing the positions of elements in a grid. Each tuple contains two integers.
 * @return A tuple representing the average position of the elements in the grid, rounded to the nearest integer.
 */
fun loopSlicingExercise(arr: List<Pair<Int, Int>>): Pair<Int, Int> {

    var totalX = 0
    var totalY = 0
    var count = 0

    for (position in arr) {
        val x = position.first
        val y = position.second

        totalX += x
        totalY += y
        count++
    }

    val avgX = totalX / count
    val avgY = totalY / count

    return Pair(avgX, avgY)
}