/**
 * This function takes a list of rock samples and returns a list of the common minerals found in all samples.
 *
 * @param rockSamples A list of rock samples, where each sample is represented as a list of minerals.
 * @return A list of common minerals found in all rock samples.
 */
fun findCommonMinerals(rockSamples: List<List<String>>): List<String> {

    if (rockSamples.isEmpty()) {
        return emptyList()
    }

    // Initialize the common minerals list with the minerals from the first rock sample
    var commonMinerals = rockSamples[0]

    // Iterate through each remaining rock sample
    for (rock in rockSamples.subList(1, rockSamples.size)) {
        // Create a new list to store the common minerals for the current rock sample
        val currentCommonMinerals = mutableListOf<String>()
        // Iterate through each mineral in the common minerals list
        for (mineral in commonMinerals) {
            // Check if the mineral is present in the current rock sample
            if (mineral in rock) {
                // If the mineral is found, add it to the currentCommonMinerals list
                currentCommonMinerals.add(mineral)
            }
        }

        // Replace the common minerals list with the new list of common minerals for the current rock sample
        commonMinerals = currentCommonMinerals
    }

    return commonMinerals
}
/**
 * This function takes a list of rock samples and returns a list of the common minerals found in all samples.
 *
 * @param rockSamples A list of rock samples, where each sample is represented as a list of minerals.
 * @return A list of common minerals found in all rock samples.
 */
fun findCommonMinerals(rockSamples: List<List<String>>): List<String> {
/**
 * This function takes a list of rock samples and returns a list of the common minerals found in all samples.
 *
 * @param rockSamples A list of rock samples, where each sample is represented as a list of minerals.
 * @return A list of common minerals found in all rock samples.
 */
fun findCommonMinerals(rockSamples: List<List<String>>): List<String> {

    if (rockSamples.isEmpty()) {
        return emptyList()
    }

    // Initialize the common minerals list with the minerals from the first rock sample
    var commonMinerals = rockSamples[0]

    // Iterate through each remaining rock sample
    for (rock in rockSamples.subList(1, rockSamples.size)) {
        // Create a new list to store the common minerals for the current rock sample
        val currentCommonMinerals = mutableListOf<String>()
        // Iterate through each mineral in the common minerals list
        for (mineral in commonMinerals) {
            // Check if the mineral is present in the current rock sample
            if (mineral in rock) {
                // If the mineral is found, add it to the currentCommonMinerals list
                currentCommonMinerals.add(mineral)
            }
        }

        // Replace the common minerals list with the new list of common minerals for the current rock sample
        commonMinerals = currentCommonMinerals
    }

    return commonMinerals
}