/**
 * Given a dictionary of mineral types and their occurrences at various locations,
 * and an index tuple representing a specific location,
 * this function returns the index of the mineral type found at that location.
 */
fun findMineralIndex(data: Map<String, List<List<Int>>>, index: Pair<Int, Int>): String {

    // Check if the index tuple is valid
    if (index.first == null || index.second == null) {
        throw IllegalArgumentException("Invalid index tuple")
    }

    // Extract the x and y coordinates from the index tuple
    val x = index.first
    val y = index.second

    // Iterate over the dictionary and find the mineral type at the specified location
    for ((mineralType, locations) in data) {
        for (location in locations) {
            if (location[0] == x && location[1] == y) {
                return mineralType
            }
        }
    }

    // If no mineral type is found at the specified location, raise an error
    throw IllegalArgumentException("No mineral type found at the specified location")
}
/**
 * Given a dictionary of mineral types and their occurrences at various locations,
 * and an index tuple representing a specific location,
 * this function returns the index of the mineral type found at that location.
 */
fun findMineralIndex(data: Map<String, List<List<Int>>>, index: Pair<Int, Int>): String {
/**
 * Given a dictionary of mineral types and their occurrences at various locations,
 * and an index tuple representing a specific location,
 * this function returns the index of the mineral type found at that location.
 */
fun findMineralIndex(data: Map<String, List<List<Int>>>, index: Pair<Int, Int>): String {

    // Check if the index tuple is valid
    if (index.first == null || index.second == null) {
        throw IllegalArgumentException("Invalid index tuple")
    }

    // Extract the x and y coordinates from the index tuple
    val x = index.first
    val y = index.second

    // Iterate over the dictionary and find the mineral type at the specified location
    for ((mineralType, locations) in data) {
        for (location in locations) {
            if (location[0] == x && location[1] == y) {
                return mineralType
            }
        }
    }

    // If no mineral type is found at the specified location, raise an error
    throw IllegalArgumentException("No mineral type found at the specified location")
}