/**
 * Given two lists of integers, x and y, the function should find the intersection of the two lists
 * and return a new list containing the common elements.
 *
 * @param x A list of integers.
 * @param y A list of integers.
 * @return A new list containing the common elements of x and y.
 *
 * Example:
 * intersectionOfBasicForLoopAndExecutingNestedLoops(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionOfBasicForLoopAndExecutingNestedLoops(x: List<Int>, y: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in x.indices) {
        for (j in y.indices) {
            if (x[i] == y[j]) {
                intersection.add(x[i])
            }
        }
    }

    return intersection
}
/**
 * Given two lists of integers, x and y, the function should find the intersection of the two lists
 * and return a new list containing the common elements.
 *
 * @param x A list of integers.
 * @param y A list of integers.
 * @return A new list containing the common elements of x and y.
 *
 * Example:
 * intersectionOfBasicForLoopAndExecutingNestedLoops(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionOfBasicForLoopAndExecutingNestedLoops(x: List<Int>, y: List<Int>): List<Int> {
/**
 * Given two lists of integers, x and y, the function should find the intersection of the two lists
 * and return a new list containing the common elements.
 *
 * @param x A list of integers.
 * @param y A list of integers.
 * @return A new list containing the common elements of x and y.
 *
 * Example:
 * intersectionOfBasicForLoopAndExecutingNestedLoops(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) -> [4, 5]
 */
fun intersectionOfBasicForLoopAndExecutingNestedLoops(x: List<Int>, y: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in x.indices) {
        for (j in y.indices) {
            if (x[i] == y[j]) {
                intersection.add(x[i])
            }
        }
    }

    return intersection
}