/**
 * This function takes two lists as input and returns a list containing the common elements between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

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

// Game developer scenario:
// The game developer wants to find the common items between two different lists of items to create a unique list containing only the items that exist in both lists.

// Create two lists of items
val list1 = listOf("sword", "shield", "helmet", "potion")
val list2 = listOf("armor", "bow", "sword", "potion")

// Call the function to find the common elements
val commonItems = findCommonElements(list1, list2)
/**
 * This function takes two lists as input and returns a list containing the common elements between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This function takes two lists as input and returns a list containing the common elements between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

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

// Game developer scenario:
// The game developer wants to find the common items between two different lists of items to create a unique list containing only the items that exist in both lists.

// Create two lists of items
val list1 = listOf("sword", "shield", "helmet", "potion")
val list2 = listOf("armor", "bow", "sword", "potion")

// Call the function to find the common elements
val commonItems = findCommonElements(list1, list2)