/**
 * Geologists often study rock samples to determine the presence of certain minerals.
 * In this exercise, you are given a list of rock samples and two minerals.
 * Your task is to write a function that returns a list of rock samples that contain both minerals.
 *
 * @param rockSamples A list of rock samples, where each rock sample is represented as a nested list
 *                    containing the minerals found in that particular sample.
 * @param mineral1 The first mineral to be searched for in the rock samples.
 * @param mineral2 The second mineral to be searched for in the rock samples.
 * @return A list of rock samples that contain both mineral1 and mineral2.
 */
fun findCommonElements(rockSamples: List<List<String>>, mineral1: String, mineral2: String): List<List<String>> {

    val commonElements = mutableListOf<List<String>>()

    for (rockSample in rockSamples) {
        if (mineral1 in rockSample && mineral2 in rockSample) {
            commonElements.add(rockSample)
        }
    }

    return commonElements
}

// Example usage
/**
 * Geologists often study rock samples to determine the presence of certain minerals.
 * In this exercise, you are given a list of rock samples and two minerals.
 * Your task is to write a function that returns a list of rock samples that contain both minerals.
 *
 * @param rockSamples A list of rock samples, where each rock sample is represented as a nested list
 *                    containing the minerals found in that particular sample.
 * @param mineral1 The first mineral to be searched for in the rock samples.
 * @param mineral2 The second mineral to be searched for in the rock samples.
 * @return A list of rock samples that contain both mineral1 and mineral2.
 */
fun findCommonElements(rockSamples: List<List<String>>, mineral1: String, mineral2: String): List<List<String>> {
/**
 * Geologists often study rock samples to determine the presence of certain minerals.
 * In this exercise, you are given a list of rock samples and two minerals.
 * Your task is to write a function that returns a list of rock samples that contain both minerals.
 *
 * @param rockSamples A list of rock samples, where each rock sample is represented as a nested list
 *                    containing the minerals found in that particular sample.
 * @param mineral1 The first mineral to be searched for in the rock samples.
 * @param mineral2 The second mineral to be searched for in the rock samples.
 * @return A list of rock samples that contain both mineral1 and mineral2.
 */
fun findCommonElements(rockSamples: List<List<String>>, mineral1: String, mineral2: String): List<List<String>> {

    val commonElements = mutableListOf<List<String>>()

    for (rockSample in rockSamples) {
        if (mineral1 in rockSample && mineral2 in rockSample) {
            commonElements.add(rockSample)
        }
    }

    return commonElements
}

// Example usage