/**
 * Given two sets and a range value, create a tuple from the intersection
 * of the sets at each iteration of the nested loops.
 *
 * @param setOne First set of geospatial coordinates
 * @param setTwo Second set of geospatial coordinates
 * @param rangeVal Range value to iterate over
 * @return Tuple containing a subset of intersection points in the form of
 *         (latitude, longitude) for each iteration
 *
 * Note:
 * - The nested loops iterate 'rangeVal' times.
 * - The function should return a tuple containing intersection points for each iteration.
 * - The intersection points should be randomly selected from the common elements of the sets.
 * - The number of intersection points for each iteration should decrease gradually.
 */
fun createTupleFromRange(setOne: Set<Any>, setTwo: Set<Any>, rangeVal: Int): List<Any> {

    val intersectionPoints = mutableListOf<Any>()
    val size = minOf(setOne.size, setTwo.size)

    for (i in rangeVal downTo 1) {
        val commonPoints = setOne.intersect(setTwo)
        val randomPoints = commonPoints.shuffled().take(i)
        intersectionPoints.addAll(randomPoints)
    }

    return intersectionPoints
}
/**
 * Given two sets and a range value, create a tuple from the intersection
 * of the sets at each iteration of the nested loops.
 *
 * @param setOne First set of geospatial coordinates
 * @param setTwo Second set of geospatial coordinates
 * @param rangeVal Range value to iterate over
 * @return Tuple containing a subset of intersection points in the form of
 *         (latitude, longitude) for each iteration
 *
 * Note:
 * - The nested loops iterate 'rangeVal' times.
 * - The function should return a tuple containing intersection points for each iteration.
 * - The intersection points should be randomly selected from the common elements of the sets.
 * - The number of intersection points for each iteration should decrease gradually.
 */
fun createTupleFromRange(setOne: Set<Any>, setTwo: Set<Any>, rangeVal: Int): List<Any> {
/**
 * Given two sets and a range value, create a tuple from the intersection
 * of the sets at each iteration of the nested loops.
 *
 * @param setOne First set of geospatial coordinates
 * @param setTwo Second set of geospatial coordinates
 * @param rangeVal Range value to iterate over
 * @return Tuple containing a subset of intersection points in the form of
 *         (latitude, longitude) for each iteration
 *
 * Note:
 * - The nested loops iterate 'rangeVal' times.
 * - The function should return a tuple containing intersection points for each iteration.
 * - The intersection points should be randomly selected from the common elements of the sets.
 * - The number of intersection points for each iteration should decrease gradually.
 */
fun createTupleFromRange(setOne: Set<Any>, setTwo: Set<Any>, rangeVal: Int): List<Any> {

    val intersectionPoints = mutableListOf<Any>()
    val size = minOf(setOne.size, setTwo.size)

    for (i in rangeVal downTo 1) {
        val commonPoints = setOne.intersect(setTwo)
        val randomPoints = commonPoints.shuffled().take(i)
        intersectionPoints.addAll(randomPoints)
    }

    return intersectionPoints
}