/**
 * Given two lists, return a new list containing only the common elements
 * between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list of the common elements between list1 and list2.
 *
 * Example:
 * '``
 * val list1 = listOf(Pair(1, 2), Pair(4, 5), Pair(7, 8))
 * val list2 = listOf(Pair(1, 2), Pair(7, 8))
 * findCommonElements(list1, list2) // [(1, 2), (7, 8)]
 * '``
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val commonElements = mutableListOf<Pair<Int, Int>>()

    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * Given two lists, return a new list containing only the common elements
 * between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list of the common elements between list1 and list2.
 *
 * Example:
 * '``
 * val list1 = listOf(Pair(1, 2), Pair(4, 5), Pair(7, 8))
 * val list2 = listOf(Pair(1, 2), Pair(7, 8))
 * findCommonElements(list1, list2) // [(1, 2), (7, 8)]
 * '``
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {
/**
 * Given two lists, return a new list containing only the common elements
 * between them.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list of the common elements between list1 and list2.
 *
 * Example:
 * '``
 * val list1 = listOf(Pair(1, 2), Pair(4, 5), Pair(7, 8))
 * val list2 = listOf(Pair(1, 2), Pair(7, 8))
 * findCommonElements(list1, list2) // [(1, 2), (7, 8)]
 * '``
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val commonElements = mutableListOf<Pair<Int, Int>>()

    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}