/**
 * You are a geologist studying rock formations. You have two lists that contain the composition of different rock samples.
 * Your task is to write a function that finds the common elements present in both lists and returns them in a new list.
 *
 * @param list1 The first rock sample composition.
 * @param list2 The second rock sample composition.
 * @return List containing the common elements present in both rock samples, in the same order as they appear in the first list.
 *
 * Example:
 * findCommonElements(listOf("quartz", "feldspar", "mica", "granite"), listOf("mica", "quartzite", "feldspar")) returns listOf("quartz", "feldspar", "mica")
 */
fun findCommonElements(list1: List<String>, list2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()
    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }
    return commonElements
}
/**
 * You are a geologist studying rock formations. You have two lists that contain the composition of different rock samples.
 * Your task is to write a function that finds the common elements present in both lists and returns them in a new list.
 *
 * @param list1 The first rock sample composition.
 * @param list2 The second rock sample composition.
 * @return List containing the common elements present in both rock samples, in the same order as they appear in the first list.
 *
 * Example:
 * findCommonElements(listOf("quartz", "feldspar", "mica", "granite"), listOf("mica", "quartzite", "feldspar")) returns listOf("quartz", "feldspar", "mica")
 */
fun findCommonElements(list1: List<String>, list2: List<String>): List<String> {
/**
 * You are a geologist studying rock formations. You have two lists that contain the composition of different rock samples.
 * Your task is to write a function that finds the common elements present in both lists and returns them in a new list.
 *
 * @param list1 The first rock sample composition.
 * @param list2 The second rock sample composition.
 * @return List containing the common elements present in both rock samples, in the same order as they appear in the first list.
 *
 * Example:
 * findCommonElements(listOf("quartz", "feldspar", "mica", "granite"), listOf("mica", "quartzite", "feldspar")) returns listOf("quartz", "feldspar", "mica")
 */
fun findCommonElements(list1: List<String>, list2: List<String>): List<String> {

    val commonElements = mutableListOf<String>()
    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }
    return commonElements
}