/**
 * Given a nested list of rock samples and a mineral as input,
 * this function returns the list of rock samples that contain the mineral.
 *
 * @param rockSamples A nested list representing different rock samples.
 * @param mineral The mineral to search for.
 * @return A list of rock samples that contain the specified mineral.
 */
fun hasMineral(rockSamples: List<List<String>>, mineral: String): List<List<String>> {

    val result = mutableListOf<List<String>>() // Create an empty list to store matching rock samples

    // Iterate over each rock sample sublist in the rockSamples list
    for (sample in rockSamples) {
        if (mineral in sample) { // Check if the mineral is present in the current rock sample
            result.add(sample) // If yes, add the rock sample to the result list
        }
    }

    return result // Return the list of rock samples containing the mineral
}

val rockSamples = listOf(
    listOf("Quartz", "Feldspar", "Mica"),
    listOf("Calcite", "Quartz", "Pyrite"),
    listOf("Gypsum", "Halite", "Quartz"),
    listOf("Mica", "Calcite", "Dolomite")
)
/**
 * Given a nested list of rock samples and a mineral as input,
 * this function returns the list of rock samples that contain the mineral.
 *
 * @param rockSamples A nested list representing different rock samples.
 * @param mineral The mineral to search for.
 * @return A list of rock samples that contain the specified mineral.
 */
fun hasMineral(rockSamples: List<List<String>>, mineral: String): List<List<String>> {
/**
 * Given a nested list of rock samples and a mineral as input,
 * this function returns the list of rock samples that contain the mineral.
 *
 * @param rockSamples A nested list representing different rock samples.
 * @param mineral The mineral to search for.
 * @return A list of rock samples that contain the specified mineral.
 */
fun hasMineral(rockSamples: List<List<String>>, mineral: String): List<List<String>> {

    val result = mutableListOf<List<String>>() // Create an empty list to store matching rock samples

    // Iterate over each rock sample sublist in the rockSamples list
    for (sample in rockSamples) {
        if (mineral in sample) { // Check if the mineral is present in the current rock sample
            result.add(sample) // If yes, add the rock sample to the result list
        }
    }

    return result // Return the list of rock samples containing the mineral
}

val rockSamples = listOf(
    listOf("Quartz", "Feldspar", "Mica"),
    listOf("Calcite", "Quartz", "Pyrite"),
    listOf("Gypsum", "Halite", "Quartz"),
    listOf("Mica", "Calcite", "Dolomite")
)