/**
 * This exercise requires you to find the elements that are present in both artist1 and artist2 lists,
 * using identity comparison.
 *
 * Implement the 'findMatchingElements' function which takes two lists as arguments and returns a list
 * containing the elements that are present in both lists, without using any built-in functions.
 *
 * Example:
 * artist1 = ['painting', 'sculpture', 'architecture', 'drawing']
 * artist2 = ['sculpture', 'drawing', 'music', 'poetry']
 * findMatchingElements(artist1, artist2) // ['sculpture', 'drawing']
 *
 * Hint: Use nested loops and the '===' operator for identity comparison.
 *
 * Difficulty: Very Difficult
 */
fun findMatchingElements(artist1: List<String>, artist2: List<String>): List<String> {

    val matchingElements = mutableListOf<String>()

    // Iterate over each element of the first artist list
    for (elem1 in artist1) {
        // Iterate over each element of the second artist list
        for (elem2 in artist2) {
            // Compare the elements using identity comparison
            if (elem1 === elem2) {
                // Add the matching element to the result list
                matchingElements.add(elem1)
            }
        }
    }

    return matchingElements
}
/**
 * This exercise requires you to find the elements that are present in both artist1 and artist2 lists,
 * using identity comparison.
 *
 * Implement the 'findMatchingElements' function which takes two lists as arguments and returns a list
 * containing the elements that are present in both lists, without using any built-in functions.
 *
 * Example:
 * artist1 = ['painting', 'sculpture', 'architecture', 'drawing']
 * artist2 = ['sculpture', 'drawing', 'music', 'poetry']
 * findMatchingElements(artist1, artist2) // ['sculpture', 'drawing']
 *
 * Hint: Use nested loops and the '===' operator for identity comparison.
 *
 * Difficulty: Very Difficult
 */
fun findMatchingElements(artist1: List<String>, artist2: List<String>): List<String> {
/**
 * This exercise requires you to find the elements that are present in both artist1 and artist2 lists,
 * using identity comparison.
 *
 * Implement the 'findMatchingElements' function which takes two lists as arguments and returns a list
 * containing the elements that are present in both lists, without using any built-in functions.
 *
 * Example:
 * artist1 = ['painting', 'sculpture', 'architecture', 'drawing']
 * artist2 = ['sculpture', 'drawing', 'music', 'poetry']
 * findMatchingElements(artist1, artist2) // ['sculpture', 'drawing']
 *
 * Hint: Use nested loops and the '===' operator for identity comparison.
 *
 * Difficulty: Very Difficult
 */
fun findMatchingElements(artist1: List<String>, artist2: List<String>): List<String> {

    val matchingElements = mutableListOf<String>()

    // Iterate over each element of the first artist list
    for (elem1 in artist1) {
        // Iterate over each element of the second artist list
        for (elem2 in artist2) {
            // Compare the elements using identity comparison
            if (elem1 === elem2) {
                // Add the matching element to the result list
                matchingElements.add(elem1)
            }
        }
    }

    return matchingElements
}