/**
 * This exercise is designed for biologists who need to find the common elements between two lists.
 *
 * Given two lists, the function should return a new list containing the elements that appear in both lists.
 * The order of elements in the new list doesn't matter, and each element should only appear once.
 *
 * For example, commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4).
 */
fun commonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val common = mutableListOf<Int>()
    
    // Iterate over each element in list1
    for (element in list1) {
        
        // Check if the element is also present in list2
        if (element in list2) {
            
            // Check if the element is already in common list
            if (element !in common) {
                
                // Add the element to the common list
                common.add(element)
            }
        }
    }
    
    return common
}
/**
 * This exercise is designed for biologists who need to find the common elements between two lists.
 *
 * Given two lists, the function should return a new list containing the elements that appear in both lists.
 * The order of elements in the new list doesn't matter, and each element should only appear once.
 *
 * For example, commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4).
 */
fun commonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This exercise is designed for biologists who need to find the common elements between two lists.
 *
 * Given two lists, the function should return a new list containing the elements that appear in both lists.
 * The order of elements in the new list doesn't matter, and each element should only appear once.
 *
 * For example, commonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4).
 */
fun commonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val common = mutableListOf<Int>()
    
    // Iterate over each element in list1
    for (element in list1) {
        
        // Check if the element is also present in list2
        if (element in list2) {
            
            // Check if the element is already in common list
            if (element !in common) {
                
                // Add the element to the common list
                common.add(element)
            }
        }
    }
    
    return common
}