/**
 * Given a list of geology data, replaces the element at the specified index with a new tuple element.
 *
 * @param geologyData A list of tuples representing geology data.
 * @param elementIndex The index of the element to be replaced.
 * @param newElement The new tuple element to replace the existing element.
 * @return The updated geology data list with the element replaced.
 */
fun replaceElement(geologyData: MutableList<Pair<String, Double>>, elementIndex: Int, newElement: Pair<String, Double>): MutableList<Pair<String, Double>> {

    if (elementIndex < 0 || elementIndex >= geologyData.size) {
        throw IndexOutOfBoundsException("Invalid index! Please provide an index between 0 and ${geologyData.size - 1}.")
    }

    geologyData[elementIndex] = newElement

    return geologyData
}

// Geology data
val rockTypes = mutableListOf(Pair("Granite", 2.65), Pair("Limestone", 2.71), Pair("Shale", 2.56), Pair("Slate", 2.72))

// Select a random index
val randomIndex = (0 until rockTypes.size).random()
/**
 * Given a list of geology data, replaces the element at the specified index with a new tuple element.
 *
 * @param geologyData A list of tuples representing geology data.
 * @param elementIndex The index of the element to be replaced.
 * @param newElement The new tuple element to replace the existing element.
 * @return The updated geology data list with the element replaced.
 */
fun replaceElement(geologyData: MutableList<Pair<String, Double>>, elementIndex: Int, newElement: Pair<String, Double>): MutableList<Pair<String, Double>> {
/**
 * Given a list of geology data, replaces the element at the specified index with a new tuple element.
 *
 * @param geologyData A list of tuples representing geology data.
 * @param elementIndex The index of the element to be replaced.
 * @param newElement The new tuple element to replace the existing element.
 * @return The updated geology data list with the element replaced.
 */
fun replaceElement(geologyData: MutableList<Pair<String, Double>>, elementIndex: Int, newElement: Pair<String, Double>): MutableList<Pair<String, Double>> {

    if (elementIndex < 0 || elementIndex >= geologyData.size) {
        throw IndexOutOfBoundsException("Invalid index! Please provide an index between 0 and ${geologyData.size - 1}.")
    }

    geologyData[elementIndex] = newElement

    return geologyData
}

// Geology data
val rockTypes = mutableListOf(Pair("Granite", 2.65), Pair("Limestone", 2.71), Pair("Shale", 2.56), Pair("Slate", 2.72))

// Select a random index
val randomIndex = (0 until rockTypes.size).random()