/**
 * Given two lists of tuples representing points in 2D space, return a list of tuples that contain the same elements
 * in both lists.
 *
 * Each tuple in the lists follows the format (x, y), where x and y represent the coordinates of a point.
 *
 * Example:
 * findCommonElements([(1, 2), (3, 4), (5, 6)], [(3, 4), (7, 8)]) => [(3, 4)]
 *
 * @param list1 A list of tuples representing points in 2D space.
 * @param list2 Another list of tuples representing points in 2D space.
 * @return A list of tuples that contain the same elements in both list1 and list2.
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

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

    for (point1 in list1) {
        for (point2 in list2) {
            if (point1.first == point2.first && point1.second == point2.second) {
                commonElements.add(point1)
            }
        }
    }

    return commonElements
}
/**
 * Given two lists of tuples representing points in 2D space, return a list of tuples that contain the same elements
 * in both lists.
 *
 * Each tuple in the lists follows the format (x, y), where x and y represent the coordinates of a point.
 *
 * Example:
 * findCommonElements([(1, 2), (3, 4), (5, 6)], [(3, 4), (7, 8)]) => [(3, 4)]
 *
 * @param list1 A list of tuples representing points in 2D space.
 * @param list2 Another list of tuples representing points in 2D space.
 * @return A list of tuples that contain the same elements in both list1 and list2.
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {
/**
 * Given two lists of tuples representing points in 2D space, return a list of tuples that contain the same elements
 * in both lists.
 *
 * Each tuple in the lists follows the format (x, y), where x and y represent the coordinates of a point.
 *
 * Example:
 * findCommonElements([(1, 2), (3, 4), (5, 6)], [(3, 4), (7, 8)]) => [(3, 4)]
 *
 * @param list1 A list of tuples representing points in 2D space.
 * @param list2 Another list of tuples representing points in 2D space.
 * @return A list of tuples that contain the same elements in both list1 and list2.
 */
fun findCommonElements(list1: List<Pair<Int, Int>>, list2: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

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

    for (point1 in list1) {
        for (point2 in list2) {
            if (point1.first == point2.first && point1.second == point2.second) {
                commonElements.add(point1)
            }
        }
    }

    return commonElements
}