/**
 * This exercise focuses on the intersection of tuples and list methods.
 *
 * Given a tuple (a) and a list (b), write a function that returns a list containing
 * the elements that are common to both a and b.
 *
 * Example:
 * - If a = (1, 2, 3, 4) and b = [3, 4, 5, 6], the function should return [3, 4].
 * - If a = (11, 22, 33, 44) and b = [55, 66, 77], the function should return an empty list.
 *
 * Your task is to complete the 'intersection' function.
 */
fun intersection(a: List<Int>, b: List<Int>): List<Int> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Int>()

    // Loop through each element in tuple a
    for (element in a) {
        // Check if the element is present in list b
        if (element in b) {
            // Append the element to commonElements list
            commonElements.add(element)
        }
    }

    // Return the list of common elements
    return commonElements
}
/**
 * This exercise focuses on the intersection of tuples and list methods.
 *
 * Given a tuple (a) and a list (b), write a function that returns a list containing
 * the elements that are common to both a and b.
 *
 * Example:
 * - If a = (1, 2, 3, 4) and b = [3, 4, 5, 6], the function should return [3, 4].
 * - If a = (11, 22, 33, 44) and b = [55, 66, 77], the function should return an empty list.
 *
 * Your task is to complete the 'intersection' function.
 */
fun intersection(a: List<Int>, b: List<Int>): List<Int> {
/**
 * This exercise focuses on the intersection of tuples and list methods.
 *
 * Given a tuple (a) and a list (b), write a function that returns a list containing
 * the elements that are common to both a and b.
 *
 * Example:
 * - If a = (1, 2, 3, 4) and b = [3, 4, 5, 6], the function should return [3, 4].
 * - If a = (11, 22, 33, 44) and b = [55, 66, 77], the function should return an empty list.
 *
 * Your task is to complete the 'intersection' function.
 */
fun intersection(a: List<Int>, b: List<Int>): List<Int> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Int>()

    // Loop through each element in tuple a
    for (element in a) {
        // Check if the element is present in list b
        if (element in b) {
            // Append the element to commonElements list
            commonElements.add(element)
        }
    }

    // Return the list of common elements
    return commonElements
}