/**
 * Given two lists of tuples, find the common elements by comparing the tuples using indexing.
 *
 * @param list1 A list of tuples.
 * @param list2 Another list of tuples.
 * @return A list of tuples containing the common elements found in both list1 and list2.
 *
 * Example:
 * list1 = [(1, 2), (3, 4), (5, 6)]
 * list2 = [(5, 6), (7, 8), (1, 2)]
 * findCommonElements(list1, list2) -> [(5, 6), (1, 2)]
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val commonElements = mutableListOf<Pair<Int, Int>>()
    for (tuple1 in list1) {
        for (tuple2 in list2) {
            if (tuple1.first == tuple2.first && tuple1.second == tuple2.second) {
                commonElements.add(tuple1)
                break
            }
        }
    }
    return commonElements
}
/**
 * Given two lists of tuples, find the common elements by comparing the tuples using indexing.
 *
 * @param list1 A list of tuples.
 * @param list2 Another list of tuples.
 * @return A list of tuples containing the common elements found in both list1 and list2.
 *
 * Example:
 * list1 = [(1, 2), (3, 4), (5, 6)]
 * list2 = [(5, 6), (7, 8), (1, 2)]
 * findCommonElements(list1, list2) -> [(5, 6), (1, 2)]
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {
/**
 * Given two lists of tuples, find the common elements by comparing the tuples using indexing.
 *
 * @param list1 A list of tuples.
 * @param list2 Another list of tuples.
 * @return A list of tuples containing the common elements found in both list1 and list2.
 *
 * Example:
 * list1 = [(1, 2), (3, 4), (5, 6)]
 * list2 = [(5, 6), (7, 8), (1, 2)]
 * findCommonElements(list1, list2) -> [(5, 6), (1, 2)]
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val commonElements = mutableListOf<Pair<Int, Int>>()
    for (tuple1 in list1) {
        for (tuple2 in list2) {
            if (tuple1.first == tuple2.first && tuple1.second == tuple2.second) {
                commonElements.add(tuple1)
                break
            }
        }
    }
    return commonElements
}