/**
 * This exercise aims to test your knowledge on finding the intersection of two lists using slicing and selection.
 *
 * Given two lists, write a function that returns a new list containing the elements that are present in both input lists.
 *
 * @param list1 A list of values.
 * @param list2 Another list of values.
 * @return A list of elements that exist in both list1 and list2.
 *
 * Example:
 * findSharedElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 * findSharedElements(listOf("apple", "banana", "orange"), listOf("banana", "grapefruit")) -> ["banana"]
 *
 * Note:
 * - The order in which the shared elements appear in the output list does not matter.
 * - If there are no shared elements, return an empty list.
 */
fun findSharedElements(list1: List<Any>, list2: List<Any>): List<Any> {

    return list1.filter { it in list2 }
}
/**
 * This exercise aims to test your knowledge on finding the intersection of two lists using slicing and selection.
 *
 * Given two lists, write a function that returns a new list containing the elements that are present in both input lists.
 *
 * @param list1 A list of values.
 * @param list2 Another list of values.
 * @return A list of elements that exist in both list1 and list2.
 *
 * Example:
 * findSharedElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 * findSharedElements(listOf("apple", "banana", "orange"), listOf("banana", "grapefruit")) -> ["banana"]
 *
 * Note:
 * - The order in which the shared elements appear in the output list does not matter.
 * - If there are no shared elements, return an empty list.
 */
fun findSharedElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise aims to test your knowledge on finding the intersection of two lists using slicing and selection.
 *
 * Given two lists, write a function that returns a new list containing the elements that are present in both input lists.
 *
 * @param list1 A list of values.
 * @param list2 Another list of values.
 * @return A list of elements that exist in both list1 and list2.
 *
 * Example:
 * findSharedElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 * findSharedElements(listOf("apple", "banana", "orange"), listOf("banana", "grapefruit")) -> ["banana"]
 *
 * Note:
 * - The order in which the shared elements appear in the output list does not matter.
 * - If there are no shared elements, return an empty list.
 */
fun findSharedElements(list1: List<Any>, list2: List<Any>): List<Any> {

    return list1.filter { it in list2 }
}