/**
 * Given two lists, find the intersection of the two lists using list slicing and nested loop.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection elements as a new list.
 */
fun listIntersection(list1: List<Any>, list2: List<Any>): List<Any> {

    val intersection = mutableListOf<Any>()

    // Iterate over the elements of the first list
    for (element1 in list1) {
        // Iterate over the elements of the second list
        for (element2 in list2) {
            // Check if the elements are equal
            if (element1 == element2) {
                // Check if the element is not already in the intersection list
                if (!intersection.contains(element1)) {
                    // Append the element to the intersection list
                    intersection.add(element1)
                }
            }
        }
    }

    return intersection
}
/**
 * Given two lists, find the intersection of the two lists using list slicing and nested loop.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection elements as a new list.
 */
fun listIntersection(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the intersection of the two lists using list slicing and nested loop.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The intersection elements as a new list.
 */
fun listIntersection(list1: List<Any>, list2: List<Any>): List<Any> {

    val intersection = mutableListOf<Any>()

    // Iterate over the elements of the first list
    for (element1 in list1) {
        // Iterate over the elements of the second list
        for (element2 in list2) {
            // Check if the elements are equal
            if (element1 == element2) {
                // Check if the element is not already in the intersection list
                if (!intersection.contains(element1)) {
                    // Append the element to the intersection list
                    intersection.add(element1)
                }
            }
        }
    }

    return intersection
}