/**
 * Given a list of tuples, each containing integers, and an index, this function compares the tuples based on the
 * values at the given index, and returns the tuple with the minimum value at that index.
 *
 * @param tuplesList A list of tuples containing integers.
 * @param index The index at which the tuples should be compared.
 * @return The tuple with the minimum value at the specified index.
 *
 * Example:
 * compareTuplesAndAccessElements(listOf(1 to 3, 2 to 5, 4 to 1, 3 to 7), 1) -> (4, 1)
 */
fun compareTuplesAndAccessElements(tuplesList: List<Pair<Int, Int>>, index: Int): Pair<Int, Int> {

    var minimumTuple: Pair<Int, Int>? = null
    var minimumValue = Int.MAX_VALUE

    for (tupleItem in tuplesList) {
        if (tupleItem.second < minimumValue) {
            minimumValue = tupleItem.second
            minimumTuple = tupleItem
        }
    }

    return minimumTuple!!
}
/**
 * Given a list of tuples, each containing integers, and an index, this function compares the tuples based on the
 * values at the given index, and returns the tuple with the minimum value at that index.
 *
 * @param tuplesList A list of tuples containing integers.
 * @param index The index at which the tuples should be compared.
 * @return The tuple with the minimum value at the specified index.
 *
 * Example:
 * compareTuplesAndAccessElements(listOf(1 to 3, 2 to 5, 4 to 1, 3 to 7), 1) -> (4, 1)
 */
fun compareTuplesAndAccessElements(tuplesList: List<Pair<Int, Int>>, index: Int): Pair<Int, Int> {
/**
 * Given a list of tuples, each containing integers, and an index, this function compares the tuples based on the
 * values at the given index, and returns the tuple with the minimum value at that index.
 *
 * @param tuplesList A list of tuples containing integers.
 * @param index The index at which the tuples should be compared.
 * @return The tuple with the minimum value at the specified index.
 *
 * Example:
 * compareTuplesAndAccessElements(listOf(1 to 3, 2 to 5, 4 to 1, 3 to 7), 1) -> (4, 1)
 */
fun compareTuplesAndAccessElements(tuplesList: List<Pair<Int, Int>>, index: Int): Pair<Int, Int> {

    var minimumTuple: Pair<Int, Int>? = null
    var minimumValue = Int.MAX_VALUE

    for (tupleItem in tuplesList) {
        if (tupleItem.second < minimumValue) {
            minimumValue = tupleItem.second
            minimumTuple = tupleItem
        }
    }

    return minimumTuple!!
}