/**
 * This function takes a list of customer names and a list of loyalty program members and returns the common names between both lists.
 * If a customer is present multiple times in either list, it should only be counted once in the result.
 *
 * @param customerList A list of customer names.
 * @param loyaltyProgramMembers A list of loyalty program member names.
 * @return A list of customer names that are both in the customerList and loyaltyProgramMembers.
 *
 * Example:
 * findCommonLoyalCustomers(listOf("John", "Emma", "Emma", "Peter"), listOf("John", "Emma", "Alice")) // Output: ["John", "Emma"]
 */
fun findCommonLoyalCustomers(customerList: List<String>, loyaltyProgramMembers: List<String>): List<String> {

    val commonCustomers = mutableListOf<String>()

    for (customer in customerList) {
        if (customer in loyaltyProgramMembers && customer !in commonCustomers) {
            commonCustomers.add(customer)
        }
    }

    return commonCustomers
}
/**
 * This function takes a list of customer names and a list of loyalty program members and returns the common names between both lists.
 * If a customer is present multiple times in either list, it should only be counted once in the result.
 *
 * @param customerList A list of customer names.
 * @param loyaltyProgramMembers A list of loyalty program member names.
 * @return A list of customer names that are both in the customerList and loyaltyProgramMembers.
 *
 * Example:
 * findCommonLoyalCustomers(listOf("John", "Emma", "Emma", "Peter"), listOf("John", "Emma", "Alice")) // Output: ["John", "Emma"]
 */
fun findCommonLoyalCustomers(customerList: List<String>, loyaltyProgramMembers: List<String>): List<String> {
/**
 * This function takes a list of customer names and a list of loyalty program members and returns the common names between both lists.
 * If a customer is present multiple times in either list, it should only be counted once in the result.
 *
 * @param customerList A list of customer names.
 * @param loyaltyProgramMembers A list of loyalty program member names.
 * @return A list of customer names that are both in the customerList and loyaltyProgramMembers.
 *
 * Example:
 * findCommonLoyalCustomers(listOf("John", "Emma", "Emma", "Peter"), listOf("John", "Emma", "Alice")) // Output: ["John", "Emma"]
 */
fun findCommonLoyalCustomers(customerList: List<String>, loyaltyProgramMembers: List<String>): List<String> {

    val commonCustomers = mutableListOf<String>()

    for (customer in customerList) {
        if (customer in loyaltyProgramMembers && customer !in commonCustomers) {
            commonCustomers.add(customer)
        }
    }

    return commonCustomers
}