/**
 * Given a list and a dictionary, create a copy of the list containing only elements that are present as keys in the dictionary.
 *
 * @param originalList A list containing elements of any type.
 * @param newDict A dictionary containing keys of any type.
 * @return A new list containing elements from the original list that are present as keys in the dictionary.
 *
 * Example:
 * intersectionDictCopying(listOf(1, 2, 3, 4), mapOf(1 to "a", 2 to "b", 5 to "c")) // [1, 2]
 */
fun intersectionDictCopying(originalList: List<Any>, newDict: Map<Any, Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Any>()
    
    // Iterate over the elements in the original list
    for (element in originalList) {
        // Check if the current element is a key in the dictionary
        if (newDict.containsKey(element)) {
            // Append the element to the commonElements list
            commonElements.add(element)
        }
    }
    
    // Return the list containing common elements
    return commonElements
}
/**
 * Given a list and a dictionary, create a copy of the list containing only elements that are present as keys in the dictionary.
 *
 * @param originalList A list containing elements of any type.
 * @param newDict A dictionary containing keys of any type.
 * @return A new list containing elements from the original list that are present as keys in the dictionary.
 *
 * Example:
 * intersectionDictCopying(listOf(1, 2, 3, 4), mapOf(1 to "a", 2 to "b", 5 to "c")) // [1, 2]
 */
fun intersectionDictCopying(originalList: List<Any>, newDict: Map<Any, Any>): List<Any> {
/**
 * Given a list and a dictionary, create a copy of the list containing only elements that are present as keys in the dictionary.
 *
 * @param originalList A list containing elements of any type.
 * @param newDict A dictionary containing keys of any type.
 * @return A new list containing elements from the original list that are present as keys in the dictionary.
 *
 * Example:
 * intersectionDictCopying(listOf(1, 2, 3, 4), mapOf(1 to "a", 2 to "b", 5 to "c")) // [1, 2]
 */
fun intersectionDictCopying(originalList: List<Any>, newDict: Map<Any, Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Any>()
    
    // Iterate over the elements in the original list
    for (element in originalList) {
        // Check if the current element is a key in the dictionary
        if (newDict.containsKey(element)) {
            // Append the element to the commonElements list
            commonElements.add(element)
        }
    }
    
    // Return the list containing common elements
    return commonElements
}